Create a new assembly and automatically put an ipt into it using iLogic

Create a new assembly and automatically put an ipt into it using iLogic

Mirtchii
Advocate Advocate
765 Views
2 Replies
Message 1 of 3

Create a new assembly and automatically put an ipt into it using iLogic

Mirtchii
Advocate
Advocate

Hi everyone,

I am having trouble writing an iLogic code, i want it to be as below example:

1. I have an ipt file named"VDV000123A".

2. I want to run the iLogic inside the ipt file which create a new iam, then we can name it in a message box"VDV000124A", then save it in the same directory with the ipt file.

3. Automatically put the ipt file "VDV000123A" in that iam "VDV000124A" and make that ipt grounded.

I try my best to figure this out myself but this one seems too hard for me at the moment. Can you guy, iLogic masters please tell me is this idea possible, and if possible, please help me with a sample of code.

I really appreciate any help.

Thank you in advanced!

 

0 Likes
Accepted solutions (1)
766 Views
2 Replies
Replies (2)
Message 2 of 3

bradeneuropeArthur
Mentor
Mentor
Accepted solution

For VBA:

Public Sub main()

Dim a As Application
Set a = ThisApplication

Dim b As PartDocument
Set b = ThisDocument

Dim c As DesignProjectManager
Set c = a.DesignProjectManager

Dim ass As AssemblyDocument
Set ass = a.Documents.Add(kAssemblyDocumentObject, c.ActiveDesignProject.TemplatesPath & "\Standard.iam", True)

ass.Activate

Dim oPos As Matrix
Set oPos = ThisApplication.TransientGeometry.CreateMatrix

    Dim oStep As Double
    oStep = 0
    
    oPos.SetTranslation ThisApplication.TransientGeometry.CreateVector(oStep, oStep, 0)

ass.ComponentDefinition.Occurrences.Add b.FullFileName, oPos
End Sub

For Ilogic:

Public Sub main()

Dim a As Application
a = ThisApplication

Dim b As PartDocument
b = b = ThisDoc.Document

Dim c As DesignProjectManager
c = a.DesignProjectManager

Dim ass As AssemblyDocument
ass = a.Documents.Add(kAssemblyDocumentObject, c.ActiveDesignProject.TemplatesPath & "\Standard.iam", True)

ass.Activate

Dim oPos As Matrix
oPos = ThisApplication.TransientGeometry.CreateMatrix

    Dim oStep As Double
    oStep = 0
    
    oPos.SetTranslation ThisApplication.TransientGeometry.CreateVector(oStep, oStep, 0)

ass.ComponentDefinition.Occurrences.Add b.FullFileName, oPos
End Sub

Or Simplified for ilogic:

Public Sub Main()

Dim a As Application
a = ThisApplication

Dim b As PartDocument
b = ThisDoc.Document

Dim c As DesignProjectManager
c = a.DesignProjectManager



Dim ass As AssemblyDocument
ass = a.Documents.Add(kAssemblyDocumentObject)

ass.Activate

Dim oPos As Matrix
oPos = ThisApplication.TransientGeometry.CreateMatrix

Dim oStep As Double
oStep = 0
    
oPos.SetTranslation (ThisApplication.TransientGeometry.CreateVector(oStep, oStep, 0),False)

ass.ComponentDefinition.Occurrences.Add(b.FullFileName,oPos)
End Sub

 

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

Message 3 of 3

Mirtchii
Advocate
Advocate

Hi Arthur,

 

Thank you very much for your help, not only one solution but 3. All of these codes work wells but with the Ilogic, it lacks some parentheses so i update and post it here for others if they need.

Such a great help, very appreciate it.

Once again, thank you Sir.

 

Public Sub Main()

Dim a As Application
a = ThisApplication

Dim b As PartDocument
b = ThisDoc.Document

Dim c As DesignProjectManager
c = a.DesignProjectManager

Dim ass As AssemblyDocument
ass = a.Documents.Add(kAssemblyDocumentObject, c.ActiveDesignProject.TemplatesPath & "\Standard.iam", True)

ass.Activate

Dim oPos As Matrix
oPos = ThisApplication.TransientGeometry.CreateMatrix

    Dim oStep As Double
    oStep = 0
    
    oPos.SetTranslation (ThisApplication.TransientGeometry.CreateVector(oStep, oStep, 0),False)

ass.ComponentDefinition.Occurrences.Add (b.FullFileName, oPos)
End Sub