Assembly level iLogic to set parameter

BJohnson2SD5H
Explorer

Assembly level iLogic to set parameter

BJohnson2SD5H
Explorer
Explorer

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

 

0 Likes
Reply
Accepted solutions (1)
203 Views
2 Replies
Replies (2)

WCrihfield
Mentor
Mentor
Accepted solution

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)

BJohnson2SD5H
Explorer
Explorer

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!

0 Likes