Okay... This morning I thought I had a nice, clear plan in my head of how to get this done, and then I didn't. Ain't nothin' easy!
DISCLAIMER: I have just enough experience programming (not in VB) to get me into trouble.
I found a nice snippet of iLogic code that allows me to copy an assembly, rename it via dialog box, and choose a new location to save the assembly and all associated parts. That gets me part of the way to where I want to be, but, first, I can't seem to run that as an external rule on a file opened silently. It just wants to run on the assembly I have open at the time (I understand why this is, I had just hoped it would see the silently opened file as the active file or at least use it if using ThisDoc.Document). I was hoping to leave iLogic mostly out of the assemblies, but if I can't then I can't.
I would like to call this from an external rule, which in turn is called by one main rule (there are about 7 different assemblies I have to be able to place, while also being able to adjust a raw width and height and the associated frame members and regular parts).
Part of my problem is getting the newly created assembly out from the copy code. Am I correct in what I'm reading in that you can't really return variables from iLogic code? If so, that makes this a bit trickier.
So, what I'm looking to do is basically this:
Start Main Rule >> Choose Compartment Configuration (each a separate rule) >> Copy Assembly and Part to New Location >> Change width and height of Skeleton Sketch >> Push Updates to Frame Generator IAM and Master Assembly >> Place Assembly into Active Assembly
The further end goal is to select which side these compartments go on and select the three faces to constrain to, while also using two of those faces (the raw opening) to derive width and height.
Lofty goals, but if anyone has any advice, I'm all ears.
Thanks!
Solved! Go to Solution.
Solved by JaneFan. Go to Solution.
Hey @Anonymous,
To get all opened documents in inventor application in external rule, please use ThisApplication.Documents to get the list, then do what you need with them them next.
I am not sure if this what you are looking for.....
I have a routine I developed that will copy a subassembly from one directory to another,
do the same for all components of the assembly(it only goes one level as my subAssemblies only have one level)
place the new subassembly in the current assembly and return the ComponentOccurrence which I then use to configure constrain the subassembly
piece is the name of the subassembly in the new design
compAsm is the original assembly
SyntaxEditor Code Snippet
oRightJamb = placeAsm("rightJamb", "drJamb", oAsmCompDef, oTG, oMatrix)
SyntaxEditor Code Snippet
Function placeAsm(piece As String, compAsm As String, oAsmCompDef as Inventor.ComponentDefinition, _ oTG As Inventor.TransientGeometry, oMatrix As Inventor.Matrix) ' Function opens an assembly file, saves it as a design file places the component ' at the origin and returns the ComponentOccurrence Dim oCompDef As ComponentDefinition Dim path As String = ThisDoc.Path Dim partDir As String = path & "\parts" Dim designDir As String = path & "\design" Dim partFile As String = partDir & "\" & compAsm & ".iam" Dim pieceFile As String = designDir & "\" & piece & ".iam" ' creat copy of new jamb assembly Dim oJambAsmDoc As AssemblyDocument Try oJambAsmDoc = ThisApplication.Documents.Open(partFile ,False) Catch MessageBox.Show("Could not find " & partFile, "placeAsm") End Try Try oJambAsmDoc.SaveAs(pieceFile , True) oJambAsmDoc.Close Catch ex As exception MessageBox.Show(ex.ToString(), "placeAsm save") MessageBox.Show(pieceFile, "placeAsm") End Try ' open new assembly, create copies of parts and replace Occ in new assembly Try oJambAsmDoc = ThisApplication.Documents.Open(pieceFile ,False) Catch MessageBox.Show("Could not find " & pieceFile, "placeAsm open new piece") End Try Dim oPartDoc As PartDocument Dim newPieceFile As String For Each part In oJambAsmDoc.ComponentDefinition.Occurrences Try oPartDoc = ThisApplication.Documents.Open(part.Definition.Document.FullFileName ,False) newPieceFile = designDir & "\" & piece & part.Name & ".ipt" oPartDoc.SaveAs(newPieceFile, False) part.Replace(newPieceFile, False) oPartDoc.Close Catch ex As exception MessageBox.Show(ex.ToString, "opening Assembly PartDoc") End Try Next oJambAsmDoc.Save oJambAsmDoc.Close Dim oOcc = ComponentOccurence Try oOcc = oAsmCompDef.Occurrences.Add(pieceFile, oMatrix) Catch ex As exception MessageBox.Show(ex.ToString(), "placeAsm save") MessageBox.Show(pieceFile, "placeAsm") End Try oMatrix.SetTranslation(oTG.CreateVector(0,0,0)) oOcc.Grounded = False Return oOcc End Function ' placeAsm
Can't find what you're looking for? Ask the community or share your knowledge.