Page 1 of 1
Property Tab Builder apply to both Global and Default config
Posted: Thu Oct 28, 2021 7:41 am
by Dwight
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"
Re: Property Tab Builder apply to both Global and Default config
Posted: Thu Oct 28, 2021 8:05 am
by ResidentAtLarge
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.
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.
Re: Property Tab Builder apply to both Global and Default config
Posted: Thu Oct 28, 2021 8:16 am
by mattpeneguy
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.
@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...
Re: Property Tab Builder apply to both Global and Default config
Posted: Thu Oct 28, 2021 8:37 am
by AlexLachance
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.
Re: Property Tab Builder apply to both Global and Default config
Posted: Thu Oct 28, 2021 8:44 am
by ResidentAtLarge
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...
That would make sense then! I did miss that in his code.
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
Posted: Fri Oct 29, 2021 9:20 pm
by Dwight
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
Re: Property Tab Builder apply to both Global and Default config
Posted: Sun Mar 20, 2022 3:23 pm
by loeb
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.
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.
Dwight would need to write a macro that deletes the "Custom Property" and makes sure that the "Configuration Specific Property" is defined.