ILogic Shrinkwrap and Revit export

ILogic Shrinkwrap and Revit export

jholland3XDLM
Advocate Advocate
2,245 Views
6 Replies
Message 1 of 7

ILogic Shrinkwrap and Revit export

jholland3XDLM
Advocate
Advocate

I would like to create an external iLogic rule that shrinkwraps an assembly and exports a Revit file. I started with code very similar to that in this article. 

https://forums.autodesk.com/t5/inventor-customization/shrinkwrap-using-ilogic/td-p/2867306

and 

https://forums.autodesk.com/t5/inventor-customization/automatic-population-of-identity-data-for-bim-...

 

This is not actually a shrinkwrap, but a derived part. That would be ok except I cant find a "Remove internal parts" option with that method. It is important to remove them.

 

Does anyone have experience with removing internal parts via iLogic? 

0 Likes
Accepted solutions (1)
2,246 Views
6 Replies
Replies (6)
Message 2 of 7

YuhanZhang
Autodesk
Autodesk
Accepted solution

Since Inventor 2019 we exposed the API for shrinkwrap, your links are old and it just use the derived assembly for shrinkwrap. So if you have Inventor 2019 or later versions, you can use ShrinkwrapDefinition.RemoveInternalParts to remove internal parts. Below is an iLogic code sample:

 

Sub Main()
	Dim oDoc As AssemblyDocument
	oDoc = ThisDoc.Document
	
	Dim oSWDoc As PartDocument
	oSWDoc = ThisApplication.Documents.Add(DocumentTypeEnum.kPartDocumentObject )
		
	Dim oSWD As ShrinkwrapDefinition
	oSWD = oSWDoc.ComponentDefinition.ReferenceComponents.ShrinkwrapComponents.CreateDefinition(oDoc.FullDocumentName)
	
	Dim oCol As ObjectCollection
	oCol = ThisApplication.TransientObjects.CreateObjectCollection
	
	Dim oOccu As ComponentOccurrence
	For Each oOccu In oDoc.ComponentDefinition.Occurrences
		oCol.Add(oOccu)
	Next
	
	oSWD.AdditionalIncludedOccurrences = oCol 
	oSWD.RemoveInternalParts = True
	
	Dim oSWComp As ShrinkwrapComponent
	oSWComp = oSWDoc.ComponentDefinition.ReferenceComponents.ShrinkwrapComponents.Add(oSWD)
End Sub

 

Hope it helps.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 3 of 7

jholland3XDLM
Advocate
Advocate

Thanks,

This works nicely. I am playing around with some of the options. How does the program determine what is an "Internal Part?" I work mostly with large open areas for air handling units.  It can sometimes be awkward to get Inventor to count something as internal. 

0 Likes
Message 4 of 7

YuhanZhang
Autodesk
Autodesk

You can try the AssemblyComponentDefinition.CreateVisibleOccurrenceFinder to get the internal occurrences in the assembly. Below is the API help for the VisibleOccurrenceFinder object:

 

http://help.autodesk.com/view/INVNTOR/2021/ENU/?guid=GUID-F056F761-46BC-4BDE-93DE-CBF8DEF7B7A4

 



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 5 of 7

simon.bjordal
Explorer
Explorer

Hello, I'm looking for the same as you did; an external iLogic rule that shrinkwraps an assembly and exports a Revit file. I've tried to use some of the code here including the links you posted, but with no luck since I don't have much experience with coding.. Is it possible for you to post the code you ended up with? That would be much apprieciated 🙂 

0 Likes
Message 6 of 7

jholland3XDLM
Advocate
Advocate

Here is the code that I ended up with. There was a big push foe me to get this up and running last year and I planed to improve it as other users started running it; after a few test runs almost everyone forgot about it and it remained in it's development state. That is how it goes I guess. I made this an external rule; so there should not be too many areas that are specific to my model. Although there are some areas that you may want to add user inputs or comment out. 

Message 7 of 7

simon.bjordal
Explorer
Explorer

Thank you very much! This was really helpful 🙂

0 Likes