Ilogic: open assembly from part

Ilogic: open assembly from part

Anonymous
Not applicable
1,076 Views
10 Replies
Message 1 of 11

Ilogic: open assembly from part

Anonymous
Not applicable

Hi

I am trying to open an assembly from a part, and then use the filename from that part and save the assembly with the same filename.

Is that possible? and can I get the drawing file for that assembly also?

0 Likes
Accepted solutions (1)
1,077 Views
10 Replies
Replies (10)
Message 2 of 11

chandra.shekar.g
Autodesk Support
Autodesk Support

@Anonymous,

 

It always the case that parts can be opened from assembly and not visa versa. Unless the parts are added into assembly, part can not linked to assembly.

 

Similarly, a part or assembly can be opened from linked drawing.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 3 of 11

marcin_otręba
Advisor
Advisor

you can do it if on save of assembly tyou will write custom iproperty in each occurrance reference document like parent_ass  in which you will store assembly.fullfilename. Then you can read this iproperty and open it from part.

But in thiis scenario part cant be used in more than in 1 assembly.

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

0 Likes
Message 4 of 11

marcin_otręba
Advisor
Advisor

sorry i just read your post again,

do you want to create assembly wchich will be na,med as part with that part in it ?

 

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

0 Likes
Message 5 of 11

Anonymous
Not applicable

Yes exactly and use the title from the part on the assembly

0 Likes
Message 6 of 11

marcin_otręba
Advisor
Advisor
Accepted solution

hi,

 

try

 

Dim name As String = ThisDoc.Document.FullFileName
Dim title As String = ThisDoc.Document.PropertySets(1).Item("title").Value
Dim ass As AssemblyDocument = ThisApplication.Documents.Add(DocumentTypeEnum.kAssemblyDocumentObject, , True)
ass.PropertySets(1).Item("title").Value = title
 Dim oTG As TransientGeometry
   oTG = ThisApplication.TransientGeometry
Dim oMatrix As Matrix
oMatrix = oTG.CreateMatrix
oMatrix.SetTranslation(oTG.CreateVector(0, 0, 0)) 
ass.ComponentDefinition.Occurrences.Add(name,oMatrix)
ass.SaveAs(Replace(name, ".ipt", ".iam"), False)

:

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

0 Likes
Message 7 of 11

Anonymous
Not applicable

That is exactly what I needed, thank you very much.

 

If I need to run an external rule on that assembly, how do I do that?

0 Likes
Message 8 of 11

marcin_otręba
Advisor
Advisor

Ilogic external configuration:

https://autodeskmfg.typepad.com/blog/2012/01/working-with-external-ilogic-rules.html

https://adndevblog.typepad.com/manufacturing/2015/01/add-external-ilogic-rule-to-event-trigger.html

i have polish version of inventor so i will not be able to post print screens to you because you will not understand 🙂

then change rule to this (it checks document sub type):

 

If ThisApplication.ActiveDocument.subtype<>"{BBF9FDF1-52DC-11D0-8C04-0800090BE8EC}" And ThisApplication.ActiveDocument.subtype<>"{E60F81E1-49B3-11D0-93C3-7E0706000000}" Then
Dim name As String = ThisDoc.Document.FullFileName
Dim title As String = ThisDoc.Document.PropertySets(1).Item("title").Value
Dim ass As AssemblyDocument = ThisApplication.Documents.Add(DocumentTypeEnum.kAssemblyDocumentObject, , True)
ass.PropertySets(1).Item("title").Value = title
 Dim oTG As TransientGeometry
   oTG = ThisApplication.TransientGeometry
Dim oMatrix As Matrix
oMatrix = oTG.CreateMatrix
oMatrix.SetTranslation(oTG.CreateVector(0, 0, 0)) 
ass.ComponentDefinition.Occurrences.Add(name,oMatrix)
ass.SaveAs(Replace(name, ".ipt", ".iam"), False)
End If

 

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

0 Likes
Message 9 of 11

Anonymous
Not applicable

Maybe I was unclear.

 

I would like to do something like this:

 

Dim name As String = ThisDoc.Document.FullFileName
Dim title As String = ThisDoc.Document.PropertySets(1).Item("title").Value
Dim ass As AssemblyDocument = ThisApplication.Documents.Add(DocumentTypeEnum.kAssemblyDocumentObject, , True)
ass.PropertySets(1).Item("title").Value = title
 Dim oTG As TransientGeometry
   oTG = ThisApplication.TransientGeometry
Dim oMatrix As Matrix
oMatrix = oTG.CreateMatrix
oMatrix.SetTranslation(oTG.CreateVector(0, 0, 0)) 
ass.ComponentDefinition.Occurrences.Add(name,oMatrix)
iLogicVB.RunExternalRule("Configure") ' This rule should run on the assembly ass.SaveAs(Replace(name, ".ipt", ".iam"), False)

 

0 Likes
Message 10 of 11

marcin_otręba
Advisor
Advisor
0 Likes
Message 11 of 11

Anonymous
Not applicable

I solved it this way:

 

assembly = ThisApplication.ActiveDocument
auto = iLogicVb.Automation
auto.RunRule(assembly,"Configure")

 

Thank you for your help

0 Likes