Boolean Subtract in Assembly

Creator
Creator

Hi, 

 

I am trying to perform a subtract operation in the Assembly enviroment and I am having some problems.

 

Firts, I want to know if the Subtract operation in the Assembly enviroment is available as an object for doing programming.

Tool.PNG

 

 

 

 

Second, I am doing the subtract operation on the part, first I copy the body with Inter-part copy and then performing the Subtract operation, the operation is done, but I recive an error at the end.

 

ErrorSub.PNG

 

Could somebody help me?

 

Code:

 

 

'ASSEMBLY
objAssembly = objApp.Documents.Add("SolidEdge.AssemblyDocument")
objApp.DoIdle()

objAssembly = objApp.ActiveDocument
collParts = objAssembly.Occurrences

occPartEjeHiper = collParts.AddByFilename(PartNameEjeHiper)
System.Threading.Thread.Sleep(1000)

occPartHiper = collParts.AddByFilename(PartNameHiper)
System.Threading.Thread.Sleep(1000)

objApp.DoIdle()

'Borrar Relación Grounded del Hiperboloide (Item(2))
collRelations = objAssembly.Relations3d
GroundRelation = collRelations.Item(2)

GroundRelation.Delete()

'Generación del Ensamble
'AXIAL
'Referencias para Relación AXIAL
HiperObjPart = occPartHiper.OccurrenceDocument
HiperModel = HiperObjPart.Models.Item(1)
HiperBody = HiperModel.Body
HiperFaces = HiperBody.Faces(SolidEdgeGeometry.FeatureTopologyQueryTypeConstants.igQueryCylinder)
HiperFace = HiperFaces.Item(1)
refHiperAxial = objAssembly.CreateReference(occPartHiper, HiperFace)

ejeObjPart = occPartEjeHiper.OccurrenceDocument
ejeModel = ejeObjPart.Models.Item(1)
ejeBody = ejeModel.Body
ejeFaces = ejeBody.Faces(SolidEdgeGeometry.FeatureTopologyQueryTypeConstants.igQueryCylinder)
ejeFace = ejeFaces.Item(1)
refEjePlanar = objAssembly.CreateReference(occPartEjeHiper, ejeFace)
objApp.DoIdle()

'Relaciones Geométrica Axial
AxialRelation = collRelations.AddAxial(
refHiperAxial,
refEjePlanar,
True)
System.Threading.Thread.Sleep(1000)

'CENTER PLANE
'Referencias del EJE para Relación CENTER PLANE
collRefplanes = ejeObjPart.RefPlanes
objPlaneTopEje = collRefplanes.Item(5)
objPlaneBottomEje = collRefplanes.Item(6)

refEjePlanar = objAssembly.CreateReference(occPartEjeHiper, objPlaneTopEje)
objPlaneTopEje.GetRootPoint(PlaceConsPoint1)

refEjePlanar2 = objAssembly.CreateReference(occPartEjeHiper, objPlaneBottomEje)
objPlaneBottomEje.GetRootPoint(PlaceConsPoint2)

'Referencias del HIPERBOLOIDE para Relación CENTER PLANE
collRefplanes = HiperObjPart.RefPlanes
objPlaneTopHiper = collRefplanes.Item(4)
objPlaneBottomHiper = collRefplanes.Item(1)

refHiperPlanar = objAssembly.CreateReference(occPartHiper, objPlaneTopHiper)
objPlaneTopHiper.GetRootPoint(TargConsPoint1)

refHiperPlanar2 = objAssembly.CreateReference(occPartHiper, objPlaneBottomHiper)
objPlaneBottomHiper.GetRootPoint(TargConsPoint2)

CenterPlaneRel = collRelations.AddCenterPlane(refEjePlanar,
refEjePlanar2,
refHiperPlanar,
refHiperPlanar2,
PlaceConsPoint1,
PlaceConsPoint2,
TargConsPoint1,
TargConsPoint2)

'Se agrega el Material de corte para Helicoide en el ASSEMBLY
occPartHeli = collParts.AddByFilename(PartNameHeli)
System.Threading.Thread.Sleep(1000)


objAssembly.SaveAs(AssemblyName)

objApp.DoIdle()

'SUBTRACT
Dim collSubtracts As SolidEdgePart.Subtracts
Dim objSubtract As SolidEdgePart.Subtract
Dim objTargetBodySubtract(0 To 1) As Object
Dim objToolBodySubtract(0 To 1) As Object
Dim objToolDirectionArray(0 To 1) As SolidEdgePart.SESubtractDirection

Dim oInterpartConstruction As SolidEdgePart.InterpartConstruction = Nothing


HiperObjPart = CType(occPartHiper.OccurrenceDocument, SolidEdgePart.PartDocument)
HeliObjPart = CType(occPartHeli.OccurrenceDocument, SolidEdgePart.PartDocument)

'HiperModel = HiperObjPart.Models.Item(1)
'HiperBody = HiperModel.Body

refHiperBody = objAssembly.CreateReference(occPartHiper, HiperBody)

oInterpartConstruction = HeliObjPart.Constructions.InterpartConstructions.Add2(occPartHeli, refHiperBody)

objAssembly.UpdatePathfinder(SolidEdgeAssembly.AssemblyPathfinderUpdateConstants.seRebuild)

HeliModel = HeliObjPart.Models.Item(1)
HeliBody = HeliModel.Body

objTargetBodySubtract(0) = HeliBody
objToolBodySubtract(0) = refHiperBody

objToolDirectionArray(0) = SolidEdgePart.SESubtractDirection.igSubtractDirectionNone



collSubtracts = HeliModel.Subtracts

objSubtract = collSubtracts.Add(1,
objTargetBodySubtract,
1,
objToolBodySubtract,
objToolDirectionArray,
SolidEdgePart.SETargetDesignBodyOption.igCreateMultipleDesignBodiesOnNonManifoldOption,
SolidEdgePart.SETargetConstructionBodyOption.igCreateMultipleConstructionBodiesOnNonManifoldOption)