Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations MintJulep on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with the function booleanFeature.add with Visual Basic

Status
Not open for further replies.

xfaure1

Computer
Jul 3, 2008
3
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

Code:
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")
Else
'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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor