All
I would like to modify Property Tab Builder code so that a user can enter a "Description" property and what they enter is applied to both Global and to the "Default" configuration. I would like this to be applied when a user runs the Property Tab Builder, without them having to do anything else. Ideally, this would work even if the user has a different configuration active.
I show some of the code below.
Is this possible?
Thanks
Dwight
<?xml version="1.0" encoding="UTF-8"?>
<CPTemplate>
<AppVersion>26</AppVersion>
<CPSheet>
<GroupBox Label="Part Properties (YOU MUST OPEN Default CONFIGURATION!)" PropName="Groupbox2" DefaultState="Expanded">
<Control Label="Custom Description (all caps, match SAP material description, 40 characters max)" PropName="Description" ApplyTo="Global" Type="TextBox" ReadOnly="False" DefaultValue="-" Mode="Text" />
HERE I WANT TO COPY THE VALUE OF THE GLOBAL "Description" TO "Description" in the "Default" CONFIGURATION.
<Control Label="SAP Part Number (enter "SEE TABLE" for tabulated parts)" PropName="SAP Part Number" ApplyTo="Config"
Property Tab Builder apply to both Global and Default config
-
- Posts: 35
- Joined: Wed Jun 02, 2021 4:31 pm
- x 31
- x 30
Re: Property Tab Builder apply to both Global and Default config
If I'm not mistaken, Solidworks always checks first to see if a configuration property exists. If it does exists, then it would ignore the values in the Global and only use the Configuration property value. If it doesnt exist, then it would take the value from the Global.Dwight wrote: ↑Thu Oct 28, 2021 7:41 am All
I would like to modify Property Tab Builder code so that a user can enter a "Description" property and what they enter is applied to both Global and to the "Default" configuration. I would like this to be applied when a user runs the Property Tab Builder, without them having to do anything else. Ideally, this would work even if the user has a different configuration active.
So unless you have another purpose for needing both values, having the Configuration property value should be good enough to use.
- mattpeneguy
- Posts: 1386
- Joined: Tue Mar 09, 2021 11:14 am
- x 2489
- x 1899
Re: Property Tab Builder apply to both Global and Default config
@ResidentAtLarge,ResidentAtLarge wrote: ↑Thu Oct 28, 2021 8:05 am If I'm not mistaken, Solidworks always checks first to see if a configuration property exists. If it does exists, then it would ignore the values in the Global and only use the Configuration property value. If it doesnt exist, then it would take the value from the Global.
So unless you have another purpose for needing both values, having the Configuration property value should be good enough to use.
He mentioned SAP. So just because what you state may be fine with just SW, it appears his data management system may require this.
@Dwight, the only thing that comes to mind from my end would be a macro...
- AlexLachance
- Posts: 2184
- Joined: Thu Mar 11, 2021 8:14 am
- Location: Quebec
- x 2364
- x 2013
Re: Property Tab Builder apply to both Global and Default config
Sometimes his part number is the part number and sometimes it's generated by the body, which is most likely a combination of his part-number with the body number, so that the "part number" becomes the "assembly number". I work that way too, but unfortunately I am of no help as we use a different method to get the true/false argument.
-
- Posts: 35
- Joined: Wed Jun 02, 2021 4:31 pm
- x 31
- x 30
Re: Property Tab Builder apply to both Global and Default config
That would make sense then! I did miss that in his code.mattpeneguy wrote: ↑Thu Oct 28, 2021 8:16 am @ResidentAtLarge,
He mentioned SAP. So just because what you state may be fine with just SW, it appears his data management system may require this.
@Dwight, the only thing that comes to mind from my end would be a macro...
I do remember seeing a macro that does this. maybe this would help?
Code: Select all
'**********************
'Copyright(C) 2020 Xarial Pty Limited
'Reference: https://www.codestack.net/solidworks-api/data-storage/custom-properties/copy-file-specific-to-configuration/
'License: https://www.codestack.net/license/
'**********************
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swCustPrpMgr As SldWorks.CustomPropertyManager
Dim swConfCustPrpMgr As SldWorks.CustomPropertyManager
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
If Not swModel Is Nothing Then
Set swCustPrpMgr = swModel.Extension.CustomPropertyManager("")
Dim vNames As Variant
Dim vTypes As Variant
Dim vValues As Variant
swCustPrpMgr.GetAll vNames, vTypes, vValues
Dim activeConfName As String
activeConfName = swModel.ConfigurationManager.ActiveConfiguration.Name
Set swConfCustPrpMgr = swModel.Extension.CustomPropertyManager(activeConfName)
Dim i As Integer
For i = 0 To UBound(vNames)
swConfCustPrpMgr.Add2 vNames(i), vTypes(i), vValues(i)
swConfCustPrpMgr.Set vNames(i), vValues(i)
Next
Else
MsgBox "Please open part or assembly"
End If
End Sub
Re: Property Tab Builder apply to both Global and Default config
Thanks to everyone. I figured it would come down to a macro.
We are transitioning from SAP to Teamcenter, which interacts with the configuration specific properties. We use Description in Windows Explorer, which takes the Global Description. Maybe that's too much to worry about, but I am used to it.
Dwight
We are transitioning from SAP to Teamcenter, which interacts with the configuration specific properties. We use Description in Windows Explorer, which takes the Global Description. Maybe that's too much to worry about, but I am used to it.
Dwight
Re: Property Tab Builder apply to both Global and Default config
ResidentAtLarge, you are correct that that is the intended behavior. If a "Configuration Specific Property" is not NULL, then it will override a "Custom Property". My VAR confirmed this for me when I discovered that it was not working this way in 2017. I'm not sure if this bug has been fixed yet.ResidentAtLarge wrote: ↑Thu Oct 28, 2021 8:05 am If I'm not mistaken, Solidworks always checks first to see if a configuration property exists. If it does exists, then it would ignore the values in the Global and only use the Configuration property value. If it doesnt exist, then it would take the value from the Global.
Dwight would need to write a macro that deletes the "Custom Property" and makes sure that the "Configuration Specific Property" is defined.