Announcements

Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.

Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Assembly level iLogic to set parameter

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
BJohnson2SD5H
174 Views, 2 Replies

Assembly level iLogic to set parameter

Hello, I'm looking to copy an iProperty from my top level assembly and send it down to the constituent part files as a parameter so I can use it to engrave the assembly part number. The code I have attempts to naively send it to every part, but it would be better to filter down to parts that begin with "T-" or "M-". I don't necessarily need the parameter to be created in every file, since it's typically only engraved on one piece, but if it were filtered, then it wouldn't hurt anything.

When I run my code, I successfully get the debug logs for the correct assembly part number to push and for each occurrence in the assembly, but the part that I have the parameter in does not receive the updated value. Any help appreciated.

Thanks!

Dim oDoc As AssemblyDocument
oDoc = ThisDoc.Document

Dim oOccs As ComponentOccurrences = oDoc.ComponentDefinition.Occurrences
Dim oOcc As ComponentOccurrence

Parameter.Quiet = True 'Don't show errors when there's no parameter to set'
iLogicVb.UpdateWhenDone = True 'Update the assembly when done'

Dim PartNumber As String
PartNumber = iProperties.Value("Project", "Part Number") 'Pulls Part Number from iProperties as variable PartNumber'
Logger.Debug("Part Number {0}", PartNumber) 'Debug is PartNumber set correctly'
For Each oOcc In oOccs
	Parameter(oOcc, "PartNum") = PartNumber
	Logger.Debug("Attempting to set value to {0}",oOcc.Name)
Next

 

2 REPLIES 2
Message 2 of 3
WCrihfield
in reply to: BJohnson2SD5H

Hi @BJohnson2SD5H.  You will need to change this:

 

Parameter(oOcc, "PartNum") = PartNumber

 

...to this:

 

Parameter(oOcc.Name, "PartNum") = PartNumber

Also, is it when the component's name start with those letters, or when the Part Number of the component starts with those letters, or file name, or some other property?  Maybe like this..?

If oOcc.Name.StartsWith("T-") Or oOcc.Name.StartsWith("M-") Then
Parameter(oOcc.Name, "PartNum") = PartNumber
End If

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 3
BJohnson2SD5H
in reply to: WCrihfield

I could've sworn I tried .Name, but that worked beautifully! Also your if statement was exactly what I meant to get to, thanks again!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report