×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Configuration macro help

Configuration macro help

Configuration macro help

(OP)
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

RE: Configuration macro help

(OP)
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

RE: Configuration macro help

(OP)
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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources