iLogic "Make Components"

iLogic "Make Components"

troyD5S9A
Contributor Contributor
3,041 Views
5 Replies
Message 1 of 6

iLogic "Make Components"

troyD5S9A
Contributor
Contributor

Hi guys,

just watching this screen cast, I do not understand where the info being pasted is coming from.

https://knowledge.autodesk.com/support/inventor-products/learn-explore/caas/screencast/Main/Details/...

Is it auto copied to the clipboard, because I can not get it to work.

 

Essentially I am trying to write iLogic to "make components" from my multibody part file.

 

Thanks.

0 Likes
Accepted solutions (3)
3,042 Views
5 Replies
Replies (5)
Message 2 of 6

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi  @troyD5S9A 

 

that video was part of the following conversation , I think the code is in the first link, however the make components part was all done manually, it was just the output of BOM information that was automated.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

https://forums.autodesk.com/t5/inventor-forum/separate-multibody-part-inside-assembly/m-p/7171674#M6...

 

https://forums.autodesk.com/t5/inventor-forum/inventor-bom-template-for-wood-working/m-p/7174641#M64...

EESignature

Message 3 of 6

troyD5S9A
Contributor
Contributor

thanks Curtis,

does this mean there is no way to "make components" using iLogic?

0 Likes
Message 4 of 6

Curtis_Waguespack
Consultant
Consultant

@troyD5S9A wrote:

thanks Curtis,

does this mean there is no way to "make components" using iLogic?


Hi @troyD5S9A 

Make Components is simply a tool set to derive out the selected solid bodies, name them, and place them in an assembly.... so while I think it would be true to say that there is no API call for running a make components function (as far as I know), it should be possible to create a routine to derive out solid bodies and and place them in an assembly, etc. I'm not aware of an example to point you to, but you might look around the Inventor Customization forum :
http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/bd-p/120

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

EESignature

Message 5 of 6

troyD5S9A
Contributor
Contributor
Accepted solution

For anyone wondering, I found this code online to be used in VBA, simply open VBA editor under tools menu, paste this code into ApplicationProject/modules/module1.

 

This will "make components" from your multibody assembly.

 

Only problem is I do not know how to change the template used as it will not convert to sheet metal. If anyone could help would be greatly appreciated.

 

' Run this inside a Multi-Solid part
Sub MakeComponentsProgrammatically()
  ' Folder to place the new components:
  ' assembly and subcomponents
  Dim f As String: f = "C:\temp\test1\"
  
  ' Make sure the folder exists
  Dim fso As Object
  Set fso = ThisApplication.FileManager.FileSystemObject
  If Not fso.FolderExists(f) Then Call fso.CreateFolder(f)
  
  Dim doc As PartDocument
  Set doc = ThisApplication.ActiveDocument
  
  ' Create the assembly
  Dim asm As AssemblyDocument
  Set asm = ThisApplication.Documents.Add(kAssemblyDocumentObject)
  
  Dim sb As SurfaceBody
  For Each sb In doc.ComponentDefinition.SurfaceBodies
    ' Create part for each body
    Dim prt As PartDocument
    Set prt = ThisApplication.Documents.Add(kPartDocumentObject)
    
    ' Set iProperties >> Project >> Description
    ' It's inside "Design Tracking Properties"
    Dim p As Property
    Set p = prt.PropertySets( _
      "{32853F0F-3444-11D1-9E93-0060B03C1CA6}")("Description")
    p.Expression = sb.name
    
    Dim dpcs As DerivedPartComponents
    Set dpcs = prt.ComponentDefinition.ReferenceComponents. _
      DerivedPartComponents
    
    Dim dpd As DerivedPartUniformScaleDef
    Set dpd = dpcs.CreateUniformScaleDef(doc.FullDocumentName)
       
    ' Exclude the other solid bodies
    Dim dpe As DerivedPartEntity
    For Each dpe In dpd.Solids
      If Not dpe.ReferencedEntity Is sb Then
        dpe.IncludeEntity = False
      End If
    Next
    
    Call dpcs.Add(dpd)
    
    ' Could have any name but we use the solid body's name
    Call prt.SaveAs(f + sb.name + ".ipt", False)
        
    ' Place an instance of it inside the assembly
    Dim mx As Matrix
    Set mx = ThisApplication.TransientGeometry.CreateMatrix()
    Call asm.ComponentDefinition.Occurrences. _
      AddByComponentDefinition(prt.ComponentDefinition, mx)
    
    ' Don't need it anymore
    Call prt.Close
  Next
  
  Call asm.SaveAs( _
    f + Left(doc.DisplayName, Len(doc.DisplayName) - 4) + _
    ".iam", False)
  Call asm.Close
End Sub

 

 

Credit to Adam Nagy

https://adndevblog.typepad.com/manufacturing/2014/06/make-components-command-implemented-via-api.htm... 

Message 6 of 6

michaelQ5BBW
Explorer
Explorer
Accepted solution
Dim sb As SurfaceBody
  For Each sb In doc.ComponentDefinition.SurfaceBodies
    ' Create part for each body
    Dim prt As PartDocument
    Set prt = ThisApplication.Documents.Add(kPartDocumentObject, oTemplatesPath & "\TEMPLATENAME.ipt", True)
 

This did the job for me. Add to the existing code the template path and template name (I just copied the part it belongs in)