Running a script on parts in assembly

Running a script on parts in assembly

jonatan.holmgren
Explorer Explorer
590 Views
1 Reply
Message 1 of 2

Running a script on parts in assembly

jonatan.holmgren
Explorer
Explorer

Trying to solve a problem, not sure it is possible tho.

 

I have a script that works well, and does what it's suppose to do.

But in order for it to work I need to open up each part and run it, which is rather taxing. 

I would like to be able to select part in the model tree in the assembly and run my script, I know how to make a script to go through each part in the assembly and run it, but it wont work in this case, as I might only want to run it on say 30 out of 70 parts.

0 Likes
591 Views
1 Reply
Reply (1)
Message 2 of 2

Curtis_Waguespack
Consultant
Consultant

Hi @jonatan.holmgren ,

 

Try something like this example, which sets the part number of each selected occurrence to be 777, note that this example might error out if a browser node that was not an occurence was selected, such as an assembly level work plane, etc.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

Dim oSelection As SelectSet
oSelection = ThisApplication.ActiveDocument.SelectSet

Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In oSelection
	iProperties.Value(oOccurrence.Name, "Project", "Part Number") = "777"
Next

EESignature

0 Likes