- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
We work with wood paneling systems and casegoods. We nest panels together when we run them through the CNC whenever we can. To nest everything together in the optimal way, we make a simple Inventor assembly containing the laid out panels and create the program from that. I want each part file and assembly file to contain a Part Number (as usual) in addition to a Program Number (as a custom property). I am updating my part and assembly templates to contain iLogic code to populate all of this automatically. I just want an automatic "Program Number" property that updates itself with minimal intervention that I can place into my drawing template and trust that it refers to the correct CNC program.
Here's an example. I have three parts:
8001.ipt
8002.ipt
8003.ipt
I decide they should be nested together to be run through the CNC. I put them into an assembly together and name the assembly 8001N.iam. At this point, I want all four files--8001, 8002, 8003, and 8001N, to have their individual "Program Name" properties updated to match the assembly filename, which is 8001N ("Main Program" in the iLogic code). Here is what I have so far--it doesn't throw any errors but it doesn't do anything, either.
Sub Main Program() MainProgram=iProperties.Value("Project", "Part Number") Dim oDoc As AssemblyDocument oDoc = ThisApplication.ActiveDocument Call SetChildProgram(oDoc, MainProgram) End Sub Sub SetChildProgram(oDoc As Document, MainProgram As String) If oDoc.ReferencedDocuments.Count > 0 Then For Each oSubDoc In oDoc.ReferencedDocuments If oSubDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject oThisDwgNumber = oSubDoc.PropertySets("Custom")("Program").Value Call SetChildProgram(oSubDoc, oThisDwgNumber) Else Try oSubDoc.PropertySets("Custom")("Drawing Number").Value = MainProgram Catch oSubDoc.PropertySets("Custom").Add(MainProgram, "Drawing Number") End try End if Next End if End Sub
Hopefully it is clear enough what I am trying to accomplish. Any advice is appreciated. I'd be happy to give more examples.
Solved! Go to Solution.