Details
Please provide the sample example for subtract.Add() method on assembly document
Solution
Below is the sample example for subtract.Add() method on assembly document,
Imports System.Runtime.InteropServices
Imports SolidEdge.Assembly.Interop
Imports SolidEdge.Part.Interop
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim objApp As SolidEdge.Framework.Interop.Application = Nothing
Dim objAsmDoc As SolidEdge.Assembly.Interop.AssemblyDocument = Nothing
Dim objPartDoc As SolidEdge.Part.Interop.PartDocument = Nothing
Try
' Create/get the application with specific settings
Try
objApp = GetObject(, "SolidEdge.Application")
Catch ex As Exception
objApp = Marshal.GetActiveObject("SolidEdge.Application")
Finally
objApp.Visible = True
End Try
objAsmDoc = objApp.ActiveDocument
Dim target1 As SolidEdge.Assembly.Interop.Occurrence
target1 = objAsmDoc.Occurrences.Item(2).OccurrenceDocument.Occurrences.Item(1)
Dim target2 As SolidEdge.Assembly.Interop.Occurrence
target2 = objAsmDoc.Occurrences.Item(2).OccurrenceDocument.Occurrences.Item(2)
Dim tool1 As Occurrence
tool1 = objAsmDoc.Occurrences.Item(1)
Dim targets(0 To 1) As Occurrence
Dim tools(0) As Occurrence
targets(0) = target1
targets(1) = target2
tools(0) = tool1
Dim dir(0) As SolidEdge.Constant.Interop.SESubtractDirection
dir(0) = SolidEdge.Constant.Interop.SESubtractDirection.igSubtractDirectionNone
Dim tool As Object
For Each tool In tools
Dim target As Object
For Each target In targets
objPartDoc = target.OccurrenceDocument
Dim asmSource As Object
asmSource = objAsmDoc.CreateReference(objAsmDoc.Occurrences.Item(1), objAsmDoc.Occurrences.Item(1).OccurrenceDocument.Models.Item(1))
Dim ipc As InterpartConstruction
ipc = objPartDoc.Constructions.InterpartConstructions.Add2(objAsmDoc.Occurrences.Item(1), asmSource)
Dim pTargets(0 To 1) As Object
pTargets(0) = objPartDoc.Models.Item(1).Body
Dim pTools(0 To 1) As Object
Dim cm As ConstructionModel
For Each cm In objPartDoc.Constructions
For Each obj In cm.Features
If (obj.Name = ipc.Name) Then
pTools(0) = cm.Body
Exit For
End If
Next
Next
Call objPartDoc.Models.Item(1).Subtracts.Add(UBound(pTargets), pTargets, UBound(pTools), pTools, dir, SolidEdge.Part.Interop.SETargetDesignBodyOption.igCreateMultipleDesignBodiesOnNonManifoldOption, SolidEdge.Part.Interop.SETargetConstructionBodyOption.igCreateMultipleConstructionBodiesOnNonManifoldOption)
Next
tool.Visible = False
Next
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
End Sub
End Class
Hardware/Software Configuration
Platform: AMD64
OS: windows
OS Version: 1064
Product: SOLID_EDGE
Application: AUTOMATION
Version: V220.0
Function: API_DOCUMENT
Ref: 002-8527764