Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Configuration macro help

Status
Not open for further replies.

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:

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
 
Replies continue below

Recommended for you

Scratch the Configuration "comments", I meant configuration description.

retVal = Configuration.Description (VB Get property)
Configuration.Description = description (VB Set property)


James Spisich
Design Engineer, CSWP
 
New wrinkle, from what I've tested, "Link to Parent Configuration" links to the global properties and not the configuration specific properties of the config that it is derived from.

I'm thinking my only recourse is to do some sort of recursive search and make a set of mirror properties on the children/derived configurations.

James Spisich
Design Engineer, CSWP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor