I'm trying to find a way to insert a part, and ground/constrain it at the orgin using iLogic. Based on my searches, it seems the best way is to replace parts, but I'm trying to get around having upwards 300 parts replaced and/or pre-placed.
My idea is to have a self-replicating and self-placing part. The part would copy and paste itself as many times as needed, then the assembly would place those parts at the orgin and ground them, then update said parts with the required dimensions. The only part I'm missing, is how to insert, and ground a part automatically.
Also, said part would have 3 different variables that would make it the correct size and put it in the correct position.
This is a filler part for another series of parts that are automatic. The trick is I could potentially need up to 12 fillers for every main part, and every single filler could have a different size to fill the gap. Then I could have anywhere from 2 to 30 main parts, which ends up being up to 360 potential parts that are potentially unique. So the idea with this self-replicating self-placing filler, is that I reduce the number of files, and significantly reduce the amount of setup I have to do, otherwise I will need to pre-setup each filler piece..
Obviously this would also make this specific piece completly autonomus and I would never have to update it in case the quantity requirements change..
Sounds like using parameters to resize parts might be an option?
Otherwise, you can use control definitions to accomplish the other parts
Dim oCommandMgr As CommandManager
oCommandMgr = ThisApplication.CommandManager
Dim oControlDef1 As ControlDefinition
Dim oSelectSet As SelectSet
oSelectSet = oDwgDoc.SelectSet
oSelectSet.Clear
oSelectSet.Select(oS2)
oControlDef1 = oCommandMgr.ControlDefinitions.Item("AssemblyBonusTools_GroundAndRootComponentCmd)
oControlDef1.Execute
@ajknexlang wrote:
Oh, well to be fair I did ask you to explain that a little more. As I said, not a programmer so I really am making this up as I go.
Rule Compile Errors in Rule2, in Assembly2.iam
Error on Line 7 : 'oDwgDoc' is not declared. It may be inaccessible due to its protection level.
Error on Line 11 : String constants must end with a double quote.
Dim oDoc As Document = ThisApplication.ActiveDocument' Add in the declaration and intialize the value
or
Dim oDoc As Document
oDoc = ThisApplication.ActiveDocument
Dim oCommandMgr As CommandManager
oCommandMgr = ThisApplication.CommandManager
Dim oControlDef1 As ControlDefinition
Dim oSelectSet As SelectSet
oSelectSet = oDwgDoc.SelectSet ' New: oDoc.SelectSet
oSelectSet.Clear
oSelectSet.Select(ThisDoc.Path & "\cube\Cube1.ipt") 'Likely need to use an occurrence here instead
oControlDef1 = oCommandMgr.ControlDefinitions.Item("AssemblyBonusTools_GroundAndRootComponentCmd") ' Missing quotes just like it says
oControlDef1.Execute
Sub Main oPartToAdd = "C:/Part.ipt" AddOccurrence(oPartToAdd) End Sub Public Sub AddOccurrence(oPartToAdd As String) ' Set a reference to the assembly component definintion. ' This assumes an assembly document is open. Dim oAsmCompDef As AssemblyComponentDefinition oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition ' Set a reference to the transient geometry object. Dim oTG As TransientGeometry oTG = ThisApplication.TransientGeometry ' Create a matrix. A new matrix is initialized with an identity matrix. Dim oMatrix As Matrix oMatrix = oTG.CreateMatrix ' Set the rotation of the matrix for a 45 degree rotation about the Z axis. Call oMatrix.SetToRotation(3.14159265358979 / 4, _ oTG.CreateVector(0, 0, 1), oTG.CreatePoint(0, 0, 0)) ' Set the translation portion of the matrix so the part will be positioned ' at (3,2,1). Call oMatrix.SetTranslation(oTG.CreateVector(3, 2, 1)) ' Add the occurrence. Dim oOcc As ComponentOccurrence oOcc = oAsmCompDef.Occurrences.Add(oPartToAdd, oMatrix)
Dim oCommandMgr As CommandManager
oCommandMgr = ThisApplication.CommandManager
Dim oControlDef1 As ControlDefinition
Dim oSelectSet As SelectSet
oSelectSet = oDoc.SelectSet
oSelectSet.Clear
oSelectSet.Select(oOcc)
oControlDef1 = oCommandMgr.ControlDefinitions.Item("AssemblyBonusTools_GroundAndRootComponentCmd")
oControlDef1.Execute End Sub
Here is an example file of what I have set up and I'm getting the error posted in the previous message.
I'm using 2015 btw
This exmple is a cube, that creates more cubes, to create a cubed cube using the quantity you specify in the XYZ range. Yes, it amuses me. More importantly, if I can get this to work I can apply it to nearly anything.
Side note, the project I'm developing this for is far far more complicated. If I can get this to work I will be able to use it to self-replicate an assembly that will require over 10,000 unique variables with somewhere around 1,000 parts. So if this works, it will significantly decrease the file size and setup required.
I apologize, you've lost me there. I haven't done anything with occurances to my knowledge.
Looks like you can just set the position when you insert the part.
This is a starting point. You are going to have to figure out/set the matrix to however you need it to properly insert the parts.
Good luck.
_____________________________________________________
Dim oDoc As Document = ThisApplication.ActiveDocument
Dim oPos As Matrix
oPos = ThisApplication.TransientGeometry.CreateMatrix()
Dim oOccurrences As Occurrences = oDoc.COmponentDefinition.ComponentOccurrences
oOccurrences.Add(ThisDoc.Path & "\cube\Cube2.ipt", oPos)
______________________________________________________