Placing multiple Instances of a component at once

Placing multiple Instances of a component at once

Anonymous
Not applicable
1,403 Views
11 Replies
Message 1 of 12

Placing multiple Instances of a component at once

Anonymous
Not applicable

Hello everyone,

 

I use a "dump assembly" of assemblies to create cut lists. I throw in multiple copies of each assembly for the job. Sometimes it can be 100 or so of each.These are not placed in any way and could be all placed at the origin. This is only for the parts list and servers no other function.

 

 

Maybe there's a better way to do this, or

 

Does anyone have a way to place multiple instances of an assembly at once? 

0 Likes
Accepted solutions (2)
1,404 Views
11 Replies
Replies (11)
Message 2 of 12

jdkriek
Advisor
Advisor

It sounds like you could insert 1 of each assembly needed and simply edit the QTY in the bom, but I'm not exactly sure what you are doing - perhaps post a screenshot of an example?

 

Would those Assemblies be all in the same folder? I've written scripts that could pull an entire directory into Inventor and ground them to the orgin. It could easily insert those assemblies multiple times specified by the user. Btw there are examples in "programming help" on how to insert parts and assemblies programmaticly.

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


0 Likes
Message 3 of 12

Anonymous
Not applicable
I will check the programming help, thanks for that suggestion.

The Assemblies may or may not be in the same folder, and it wouldn't be all of them if they were. Just being able to inset one assembly multiple times would be great. I was hoping for a dialog that would query the number of times I would want it inserted. I'll find the programming help when I get back to the office. Even if it wouldn't help me now I'd sure be happy to see some scripts or snippets of something like you mention.

Thanks.
0 Likes
Message 4 of 12

Stakin
Collaborator
Collaborator

you can only add a ""Virtual components" other than a real one

see the link :Add Multiple Virtual Components

http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/Add-Multiple-Virtual-Components/m-p/42...

 

 

 

0 Likes
Message 5 of 12

jdkriek
Advisor
Advisor
Accepted solution

Stakin, he's not using Virtual Components

 

Nick, Here's an example btw using iLogic:

 

' File path to use
oPath = "C:\Temp\insert.iam"

Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim oMatrix As Matrix = oTG.CreateMatrix
Dim oOccurrence As ComponentOccurrence

' Insert Loop
Dim Total As Integer
Total = InputBox("Type How Many", "Insert", "1")
For X = 1 To Total 
	' Place Assy
	oOccurrence = oAsmCompDef.Occurrences.Add(oPath, oMatrix)
	oMatrix.SetTranslation(oTG.CreateVector(0, 0, 0)) 
	oOccurrence.Grounded = True 
Next
ThisApplication.ActiveView.Fit

You could also get real tricky and prompt the user for the file path 😉

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


0 Likes
Message 6 of 12

Stakin
Collaborator
Collaborator

In this way,it may be Consume a large amount of system resources.(This is only for the parts list and servers no other function.)

I think the Virtual Components is a best solution.

0 Likes
Message 7 of 12

jdkriek
Advisor
Advisor

You also have to think about the time it takes to create Virtual Components for Assemblies he already has made. Even if you are adding it to the parts list via Custom Part (equivalent to VC) he would STILL have to fill out all the information for each Assy.

 

Inserting 1 instance of each Assy then editing the QTY in the parts list seems like the most practical solution if he's just using it to create a BOM. Mainly because he doesn't have to create anything new or fill in properties again. But I also wanted to provide an example of inserting multiple instances of Assy - which he stated he would find useful for future reference.

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


0 Likes
Message 8 of 12

Stakin
Collaborator
Collaborator

As you say,it may have a way to "Copy" All the Useful  information from the Assm to Virtual Components.

    Dim asmDoc As AssemblyDocument
    asmDoc = ThisApplication.ActiveDocument
    Dim InsertDoc As Document
Try
InsertDoc =ThisApplication.Documents.ItemByName("C:\XXX\XXX.XXX")
Catch
InsertDoc =ThisApplication.Documents.Open("C:\XXX\XXX.XXX",0) end Try
    Dim occs As ComponentOccurrences   occs = asmDoc.ComponentDefinition.Occurrences     Dim oPropSet As PropertySet Dim oPropSets As ProPertySets oPropSets= InsertDoc.ProPertySets     Dim identity As Matrix identity = ThisApplication.TransientGeometry.CreateMatrix        Dim virtOcc As ComponentOccurrence virtOcc = occs.AddVirtual("TestVirtual", identity) Dim oPropSetsV As ProPertySets oPropSetsV=oInsertDoc.ProPertySets For Each oPropSet in oPropSets Dim oPropSetV As PropertySet Dim oProp As Property oPropV=oPropSetsV.Item(oPropSet.InternalName) For Each oProp In oPropSet
Dim oPropV As Property oPropV=oPropV.Item(oProp.DisplayName) oPropV.Value=oProp.Value Next Next InsertDoc.Close
    Dim Total As Integer Total = InputBox("Type How Many", "Insert", "1") Dim X As Integer For X = 1 To Total Call occs.AddByComponentDefinition(virtOcc.Definition, identity) Next

 

 

0 Likes
Message 9 of 12

Anonymous
Not applicable

Virtual Components might be a solution, so might just changing the qty in the BOM, but the former leads down a road I'm not yet prepared to take 🙂 and the latter is another spot where errors could easily be generated - I'm assuming you mean manually entering the qty changes.

 

I've attached a dwg with the latest file I've done this with. It is a simple collection, only 3 assemblies, but with many parts each. Now that I'm looking at it, there are some parts that are common to each assembly, and some that are unique, so a simple multiplication in the BOM wouldn't be so simple. I'll work on some of the code that has been presented and look into the programming help now. 

 

Thanks for all the suggestions Stakin and Jdkriek,I appreciate your efforts!

0 Likes
Message 10 of 12

jdkriek
Advisor
Advisor

After seeing your drawing, I'd stick with what works for you - inserting the assemblies.

 

You can start with the example I posted. Let me know if you need any help.

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


0 Likes
Message 11 of 12

Anonymous
Not applicable
Accepted solution

Jdkriek, I used your example - thank you! and added a dialog to get pick the file name (Thanks to Curtis W. for that). Here's my iLogic:

 

'present a File Selection dialog
Dim oFileDlg As inventor.FileDialog = Nothing
InventorVb.Application.CreateFileDialog(oFileDlg)
oFileDlg.InitialDirectory = oOrigRefName
oFileDlg.CancelError = True
' Define the filter to select part and assembly files or any file.
'oFileDlg.Filter = "Inventor Files (*.iam;*.ipt)|*.iam;*.ipt|All Files (*.*)|*.*"
oFileDlg.Filter = "Inventor Files (*.iam;*.ipt)|*.iam;*.ipt"
' Set the title for the dialog.
oFileDlg.DialogTitle = "Choose File to Insert"
On Error Resume Next
oFileDlg.ShowOpen()
If Err.Number <> 0 Then
Return
ElseIf oFileDlg.FileName <> "" Then
selectedfile = oFileDlg.FileName
End If
'MessageBox.Show("You selected: " & selectedfile , "iLogic")

' File path to use
oPath=selectedfile

Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim oMatrix As Matrix = oTG.CreateMatrix
Dim oOccurrence As ComponentOccurrence

' Insert Loop
Dim Total As Integer
Total = InputBox("Type How Many", "Insert", "1")
If Err.Number <> 0 Then  'if there is an error it returns out
Return
ElseIf Err.Number = 0 Then 'if there is no error, it keeps working, else returns out
For X = 1 To Total 
	' Place Assy
	oOccurrence = oAsmCompDef.Occurrences.Add(oPath, oMatrix)
	oMatrix.SetTranslation(oTG.CreateVector(0, 0, 0)) 
	oOccurrence.Grounded = True 
Next
End If
ThisApplication.ActiveView.Fit

 

I'm very happy with this - I'm sure I'll tweak it a bit here and there, but this is great!!

 

Thanks all! 

Message 12 of 12

jdkriek
Advisor
Advisor

Glad I could help 😉

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


0 Likes