Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Write SurfaceBodies directly to file

2 REPLIES 2
Reply
Message 1 of 3
dg2405
114 Views, 2 Replies

Write SurfaceBodies directly to file

I think with this Method we can write a Collection with surfacebodies directly to a file:

ThisApplication.TransientBRep.WriteToFile()

 dg2405_0-1705620565142.png

Unfortunately i don't work as i expect that. When writing to an empty ipt-file, the file is corrupt and could not be opened. Writing to a txt-file works, there are long informations about the geometry. So can i write with that method to an ipt? What is the "Optional Format As String"?

2 REPLIES 2
Message 2 of 3
dg2405
in reply to: dg2405

Or maybe someone has a good way to add a large collection with BRep surfacebodies to an empty ipt, without doing it one by one? This takes to long for me. Currently i add each with NonParametricBaseFeature

Message 3 of 3
J-Camper
in reply to: dg2405

@dg2405,

 

When looking at the help file for the .ReadFromFile TransientBRep method, there is an example of reading fram a sat file.  looks like you can write to sat file then read from sat file with these examples:

Run in donor part:

Dim tempfile As String =  System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop) &"\temp_sat.sat"
Dim bodyCol As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
For Each sb As SurfaceBody In ThisDoc.Document.ComponentDefinition.SurfaceBodies
	If Not sb.IsSolid Then Continue For
	bodyCol.Add(sb)
Next
ThisApplication.TransientBRep.WriteToFile(bodycol, tempfile)

Run in New Part:

Dim tempfile As String = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop) &"\temp_sat.sat"
For Each sb As SurfaceBody In ThisApplication.TransientBRep.ReadFromFile(tempfile)
	Dim npbfDef As NonParametricBaseFeatureDefinition = ThisDoc.Document.ComponentDefinition.Features.NonParametricBaseFeatures.CreateDefinition
	Dim newCol As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
	newCol.Add(sb)
	npbfDef.BRepEntities = newCol
	npbfDef.OutputType = BaseFeatureOutputTypeEnum.kSolidOutputType
	ThisDoc.Document.ComponentDefinition.Features.NonParametricBaseFeatures.AddByDefinition(npbfDef)
Next

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report