DesignerGuy16
Mechanical
- Jun 18, 2008
- 303
I've got a macro to help with custom properties. I have two problems currently:
1) The macro as is deletes any configuration comments when it runs. I know it's the center "" in:
CurrentDoc.EditConfiguration ConfigName, ConfigName, "", PartNumber1, 1, 0, 0, 1, 385
What I haven't been able to figure out is how to add in a recursive search using the method below:
Comment = Configuration.Comment (VB Get property)
Configuration.Comment = Comment (VB Set property)
2) The macro sets every configuration to a user specified part number linking to my custom properties. Problem here is any derived configurations glitch out and only want to read from the global custom properties. I need to keep them linked to their parent instead of a user specified property link.
I'm guessing it will be something to do with the:
Derived = Configuration.IsDerived ( )
And using a check, I can run them through a mirror command that will set the Configuration BOM type to "Link to Parent".
Comments on the macro: To run off a button, set the macro method to: PropCode.Main
I used the macro record feature to do this section as I couldn't get it to work otherwise for some reason. The rest of the macro works as intended, and this is really the only part that will change anything with the configurations.
The section that really pertains to the above issues is:
James Spisich
Design Engineer, CSWP
1) The macro as is deletes any configuration comments when it runs. I know it's the center "" in:
CurrentDoc.EditConfiguration ConfigName, ConfigName, "", PartNumber1, 1, 0, 0, 1, 385
What I haven't been able to figure out is how to add in a recursive search using the method below:
Comment = Configuration.Comment (VB Get property)
Configuration.Comment = Comment (VB Set property)
2) The macro sets every configuration to a user specified part number linking to my custom properties. Problem here is any derived configurations glitch out and only want to read from the global custom properties. I need to keep them linked to their parent instead of a user specified property link.
I'm guessing it will be something to do with the:
Derived = Configuration.IsDerived ( )
And using a check, I can run them through a mirror command that will set the Configuration BOM type to "Link to Parent".
Comments on the macro: To run off a button, set the macro method to: PropCode.Main
I used the macro record feature to do this section as I couldn't get it to work otherwise for some reason. The rest of the macro works as intended, and this is really the only part that will change anything with the configurations.
The section that really pertains to the above issues is:
Code:
Sub ConfigSetup()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Set SelMgr = Part.SelectionManager
swApp.ActiveDoc.ActiveView.FrameState = 1
' Set Config Specific name to $PRP:"PartShtSize"$PRP:"PartBase"
PartNumber1 = "$PRP:" & """" & "PartShtSize" & """" & "$PRP:" & """" & "PartBase" & """"
ConfigCount = CurrentDoc.GetConfigurationCount
ConfigNames = CurrentDoc.GetConfigurationNames
For i = 0 To ConfigCount - 1
ConfigName = ConfigNames(i)
boolstatus = CurrentDoc.Extension.SelectByID2("ConfigName", "CONFIGURATIONS", 0, 0, 0, False, 0, Nothing, 0)
CurrentDoc.EditConfiguration ConfigName, ConfigName, "", PartNumber1, 1, 0, 0, 1, 385
Next i
ConfigSorted = False
Do While Not ConfigSorted
ConfigSorted = True
For i = 0 To PropCode.ConfigCount - 2 Step 1
If PropCode.ConfigNames(i + 1) < PropCode.ConfigNames(i) Then
DoEvents
ConfigSorted = False
PropCode.ConfigTemp = PropCode.ConfigNames(i)
PropCode.ConfigNames(i) = PropCode.ConfigNames(i + 1)
PropCode.ConfigNames(i + 1) = PropCode.ConfigTemp
End If
Next i
Loop
Call EnterConfigGenProps
End Sub
James Spisich
Design Engineer, CSWP