Welcome to 3DCADForums

Join our CAD community forums where over 25,000 users interact to solve day to day problems and share ideas. We encourage you to visit, invite you to participate and look forward to your input and opinions. Acrobat 3D, AutoCAD, Catia, Inventor, IronCAD, Creo, Pro/ENGINEER, Solid Edge, SolidWorks, and others.

Register Log in

Problem with the function booleanFeature.add with Visual Basic



Hello everybody

I try to do a substract between two solids.
I created a DocumentPart.
I copy two parts on this new document.
the first created a model in objDoc.Models.
the second add a Item in objDoc.Constructions.CopyConstructions
and add a item in objDoc.Models(1).Features

So, I process this function :
objDoc.Models.Item(1).BooleanFeatures.Add with goods parameters but it fails!

I don't understand. Does somebody can help me?

thanks a lot

Xavier FAURE

Module ModuleVolume

Sub Main()
'Declare the program variables.
Dim objApp As Object = Nothing
Dim objDocs As Object = Nothing

'Turn on error handling.
On Error Resume Next

'Connect to a running instance of Solid Edge.
objApp = GetObject(, "SolidEdge.Application")
If objApp Is Nothing Then
'Error message
MsgBox("The Application is closed. The program is going to open it.")
'Start Solid Edge.
objApp = CreateObject("SolidEdge.Application")
End If

'Turn off error handling.
On Error GoTo 0

'Make the application window visible.
objApp.Visible = True

'Access the Documents collection.
objDocs = objApp.Documents

Dim objDoc As Object

'Find out if any documents are open.
If objDocs.Count = 0 Then
'Add an Part document.
objDoc = objDocs.Add("SolidEdge.PartDocument")
'Access the currently open document.
'MsgBox("Connection of part which is opened")
objDoc = objApp.ActiveDocument
End If

Dim objModel As SolidEdgePart.Model = objDoc.Models(1)
MsgBox("Number of shells ( in Models(1).Body ) : " + objModel.Body.Shells.Count.ToString)
MsgBox("Number of features : " + objModel.Features.Count.ToString)
Dim objConstructions As SolidEdgePart.Constructions = objDoc.Constructions
MsgBox("Number of constuctions : " + objConstructions.Count.ToString)
Dim objCopyConstructions As SolidEdgePart.CopyConstructions = objConstructions.CopyConstructions
MsgBox("Number of CopyConstructions : " + objCopyConstructions.Count.ToString)

Dim objBooleanFeatures As SolidEdgePart.BooleanFeatures = objDoc.Models.Item(1).BooleanFeatures

'The number of solid to do the boolean opertation
Dim NumberOfTools As Integer = 1
'A array which contains these solids
Dim Tools() As Object = {objConstructions.Item(1).Body}
'A member of the BooleanFeatureConstants constant set that specifies the type of Boolean operation to perform.
Dim Operation As SolidEdgePart.BooleanFeatureConstants = SolidEdgePart.BooleanFeatureConstants.seBooleanSubtract

MsgBox("Clic on Ok to process the function")

'Process the boolean fonction
objBooleanFeatures.Add(NumberOfTools, Tools, Operation)

MsgBox("It's Ok")

End Sub

End Module