I think with this Method we can write a Collection with surfacebodies directly to a file:
ThisApplication.TransientBRep.WriteToFile()
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"?
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
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.