These are lines I extracted from a command in my add-in. It behaves correctly in a standard part but not in a sheet metal part. Please check the video or follow these steps:
- Paste the rule below into an external rule.
- Open a sheet metal part.
- Run the rule twice, selecting an IPT file each time.
- If you check the log, you will see that you are supposed to create a solid, but it is not visible in the view.
Sub main()
Dim thisCmpDef As PartComponentDefinition = ThisDoc.Document.ComponentDefinition
Dim fileToimport = SelectIptFromDisk()
Dim importedCmpDef As PartComponentDefinition = ThisApplication.Documents.Open(fileToimport, False).ComponentDefinition
Dim importedBody As SurfaceBody = importedCmpDef.SurfaceBodies.Item(1)
Dim oCollection As ObjectCollection
oCollection = ThisApplication.TransientObjects.CreateObjectCollection
oCollection.Add(importedBody)
Dim baseFeatureDef As NonParametricBaseFeatureDefinition
baseFeatureDef = thisCmpDef.Features.NonParametricBaseFeatures.CreateDefinition
baseFeatureDef.BRepEntities = oCollection
baseFeatureDef.OutputType = BaseFeatureOutputTypeEnum.kSolidOutputType
Logger.Info(baseFeatureDef.OutputType)
Dim oBaseFeature1 As NonParametricBaseFeature =
thisCmpDef.Features.NonParametricBaseFeatures.AddByDefinition(baseFeatureDef)
Logger.Info(oBaseFeature1.IsSolid)
End Sub
Function SelectIptFromDisk() As String
Dim openFileDialog As Inventor.FileDialog = Nothing
InventorVb.Application.CreateFileDialog(openFileDialog)
openFileDialog.DialogTitle = "Select .ipt File"
openFileDialog.Filter = "Autodesk Inventor Files (*.ipt)|*.ipt"
openFileDialog.ShowOpen()
Return openFileDialog.FileName
End Function