Good Morning or Afternoon,
I'm no stranger to iLogic but I'm still very much a amateur with coding, I've created code that auto creates pdfs of drawings once its saved to a specific folder or creating a fluctuating stair that changes to width and any height. But today I am asking whenever I import a file from content center and the part number in iProperties always changes, if you change the length or the size of that Content Center Part back to the default even if I changed it prior to the saved file name of that part. I want to create code that at assembly level will go through all parts and if its different then the saved ipt file it will change it to that name rather then the default content name it puts there. I've come across a few but I just would like a definitive answer or suggestions. It's been almost a year since I've touched iLogic.
Solved! Go to Solution.
Good Morning or Afternoon,
I'm no stranger to iLogic but I'm still very much a amateur with coding, I've created code that auto creates pdfs of drawings once its saved to a specific folder or creating a fluctuating stair that changes to width and any height. But today I am asking whenever I import a file from content center and the part number in iProperties always changes, if you change the length or the size of that Content Center Part back to the default even if I changed it prior to the saved file name of that part. I want to create code that at assembly level will go through all parts and if its different then the saved ipt file it will change it to that name rather then the default content name it puts there. I've come across a few but I just would like a definitive answer or suggestions. It's been almost a year since I've touched iLogic.
Solved! Go to Solution.
Solved by Andrii_Humeniuk. Go to Solution.
Hi @SleikerBF
Can you clarify with short bullets the sequence of operations and what variants your working with, will it be filename/part number/description. Are the cc files custom? Are you exchanging custom for standard etc?
It can be a little hard to grasp the interactions when instructions are in paragraph form and are lacking the terminology your seeing when interacting with the files.
Hi @SleikerBF
Can you clarify with short bullets the sequence of operations and what variants your working with, will it be filename/part number/description. Are the cc files custom? Are you exchanging custom for standard etc?
It can be a little hard to grasp the interactions when instructions are in paragraph form and are lacking the terminology your seeing when interacting with the files.
Hi @SleikerBF . I hope I understood you correctly. You have parts imported from the content center, which you change and resave, but the information in the PartNumber of these parts is not updated. So you need to update the PartNumber based on the filename.
This code searches your assembly for imported content center components and checks that the PartNumber and filename match, and if they differ, a new PartNumber is written.
Public Sub Main()
Dim oADoc As AssemblyDocument = TryCast(ThisDoc.Document, AssemblyDocument)
If oADoc Is Nothing Then Exit Sub
Dim oOccs As ComponentOccurrences = oADoc.ComponentDefinition.Occurrences
For Each oCCDoc As PartDocument In oADoc.AllReferencedDocuments.OfType(Of PartDocument)
If oOccs.AllReferencedOccurrences(oCCDoc.ComponentDefinition).Count = 0 Or
Not oCCDoc.IsModifiable Then Continue For
Try : propSet = oCCDoc.PropertySets("{B9600981-DEE8-4547-8D7C-E525B3A1727A}")
Catch : Continue For : End Try
Dim sNameCC As String = IO.Path.GetFileNameWithoutExtension(oCCDoc.DisplayName)
Dim oPNumb As Inventor.Property = oCCDoc.PropertySets("Design Tracking Properties")("Part Number")
If Not oPNumb.Value = sNameCC Then oPNumb.Value = sNameCC
Next
End Sub
Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor
LinkedIn | My free Inventor Addin | My Repositories
Did you find this reply helpful ? If so please use the Accept as Solution/Like.
Hi @SleikerBF . I hope I understood you correctly. You have parts imported from the content center, which you change and resave, but the information in the PartNumber of these parts is not updated. So you need to update the PartNumber based on the filename.
This code searches your assembly for imported content center components and checks that the PartNumber and filename match, and if they differ, a new PartNumber is written.
Public Sub Main()
Dim oADoc As AssemblyDocument = TryCast(ThisDoc.Document, AssemblyDocument)
If oADoc Is Nothing Then Exit Sub
Dim oOccs As ComponentOccurrences = oADoc.ComponentDefinition.Occurrences
For Each oCCDoc As PartDocument In oADoc.AllReferencedDocuments.OfType(Of PartDocument)
If oOccs.AllReferencedOccurrences(oCCDoc.ComponentDefinition).Count = 0 Or
Not oCCDoc.IsModifiable Then Continue For
Try : propSet = oCCDoc.PropertySets("{B9600981-DEE8-4547-8D7C-E525B3A1727A}")
Catch : Continue For : End Try
Dim sNameCC As String = IO.Path.GetFileNameWithoutExtension(oCCDoc.DisplayName)
Dim oPNumb As Inventor.Property = oCCDoc.PropertySets("Design Tracking Properties")("Part Number")
If Not oPNumb.Value = sNameCC Then oPNumb.Value = sNameCC
Next
End Sub
Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor
LinkedIn | My free Inventor Addin | My Repositories
Did you find this reply helpful ? If so please use the Accept as Solution/Like.
This worked great, thank you!
This worked great, thank you!
Can't find what you're looking for? Ask the community or share your knowledge.