Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.
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
Solved! Go to Solution.
Solved by WCrihfield. Go to 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
(Not an Autodesk Employee)
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.