Part Rule to Run while Edit in Place at Assembly Level

Part Rule to Run while Edit in Place at Assembly Level

kennyj
Collaborator Collaborator
482 Views
2 Replies
Message 1 of 3

Part Rule to Run while Edit in Place at Assembly Level

kennyj
Collaborator
Collaborator

With the help of this forum, I have the following rule which works great a the part level, external rule.

 

My users though, have tried to run the rule while in an assembly, editing the part in place.  The rule as written adds the parameters at the assembly level, not to the activated part file.

 

Can one of you gurus show me how to have my rule apply the parameters to the part that is being edited not the assembly that the part was accessed from?

 

Thank you in advance,

 

Kenny

 

Format:HTML Format Version:1.0 StartHTML: 165 EndHTML: 6532 StartFragment: 314 EndFragment: 6500 StartSelection: 314 EndSelection: 314SyntaxEditor Code Snippet

Sub Main()
Dim oDoc As PartDocument
oDoc=ThisApplication.ActiveDocument

Dim oUserParam1 As UserParameter
oUserParam1=oDoc.ComponentDefinition.Parameters.UserParameters.AddByValue("CMF_COORD_X", 0, UnitsTypeEnum.kFootLengthUnits)


Dim oUserParam2 As UserParameter
oUserParam=oDoc.ComponentDefinition.Parameters.UserParameters.AddByValue("CMF_COORD_Y", 0, UnitsTypeEnum.kFootLengthUnits)

Dim oUserParam3 As UserParameter
oUserParam3=oDoc.ComponentDefinition.Parameters.UserParameters.AddByValue("CMF_COORD_Z", 0, UnitsTypeEnum.kFootLengthUnits)


End Sub

 

0 Likes
Accepted solutions (1)
483 Views
2 Replies
Replies (2)
Message 2 of 3

Owner2229
Advisor
Advisor
Accepted solution

Hey Kenny, here you go:

 

Sub Main()
Dim oDoc As Object = ThisApplication.ActiveEditObject
If Not TypeOf oDoc Is PartDocument Then Exit Sub

Dim oUP As UserParameters = oDoc.ComponentDefinition.Parameters.UserParameters
Dim oUP1 As UserParameter = oUP.AddByValue("CMF_COORD_X", 0, UnitsTypeEnum.kFootLengthUnits)
Dim oUP2 As UserParameter = oUP.AddByValue("CMF_COORD_Y", 0, UnitsTypeEnum.kFootLengthUnits)
Dim oUP3 As UserParameter = oUP.AddByValue("CMF_COORD_Z", 0, UnitsTypeEnum.kFootLengthUnits)
End Sub
Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
Message 3 of 3

kennyj
Collaborator
Collaborator

@Owner2229,

 

Worked like a charm.  Thank you.

 

I appreciate you showing me how to clean up my code a bit, too.

 

Very much appreciated, Mike!

 

Kenny

0 Likes