Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Scripting for isolating plane or geometry elements

Status
Not open for further replies.

Charlie

Mechanical
Dec 28, 2015
15
Can anyone tell me about any function that can be used to isolate plane or surface created using scripting.
I need to isolate a plane in a part so that i can cut and paste it into another in same location without references.
With references it will not be pasted.
Please Give some suggestion..
 
Replies continue below

Recommended for you

i make a extracted plane in part using scripting and then add it to selection set and use same command.
but didn't work. Is this command works on current selection set.
My program is as follows

Sub CATMain()
Dim partDocument1 As Document
Set partDocument1 = CATIA.ActiveDocument
Dim part1 As Part
Set part1 = partDocument1.Part
Dim hybridShapeFactory1 As Factory
Set hybridShapeFactory1 = part1.HybridShapeFactory
Dim bodies1 As Bodies
Set bodies1 = part1.Bodies
Dim body1 As Body
Set body1 = bodies1.Item("PartBody")
Dim shapes1 As Shapes
Set shapes1 = body1.Shapes
Dim pad1 As Shape
Set pad1 = shapes1.Item(shapes1.Count)
part1.InWorkObject = pad1
Dim Selection1 As selection
Set Selection1 = partDocument1.selection
Dim selection2
Set selection2 = Selection1
Dim InputObjectType(0), Status
InputObjectType(0) = "PlanarFace"
Status = selection2.SelectElement2(InputObjectType, "Select a Planar Face:", True)
Dim reference1 As Reference
Set reference1 = Selection1.Item2(1).Reference
Dim hybridShapeExtract1 As HybridShapeExtract
Set hybridShapeExtract1 = hybridShapeFactory1.AddNewExtract(reference1)
hybridShapeExtract1.PropagationType = 3
hybridShapeExtract1.ComplementaryExtract = False
hybridShapeExtract1.IsFederated = False
body1.InsertHybridShape hybridShapeExtract1
part1.InWorkObject = hybridShapeExtract1
part1.Update
Selection1.Clear
Selection1.Add hybridShapeExtract1
CATIA.StartCommand ("Isolate")
part1.Update
End Sub

 
Hi,

I've modified your code a little bit, hope is what you want

Code:
Language="VBSCRIPT"

Sub CATMain()
Set partDocument1 = CATIA.ActiveDocument
Set part1 = partDocument1.Part
Set bodies1 = part1.Bodies
Set body1 = bodies1.Item("PartBody")

Set hybridBodies1 = body1.HybridBodies
Set hybridBody1 = hybridBodies1.Add()
hybridBody1.Name = "To_be_isolated"
part1.Update 
Set hybridShapeFactory1 = part1.HybridShapeFactory
Set shapes1 = body1.Shapes


Dim Selection1 As selection
Set Selection1 = partDocument1.selection
Dim selection2
Set selection2 = Selection1
Dim InputObjectType(0), Status
InputObjectType(0) = "PlanarFace"
Status = selection2.SelectElement2(InputObjectType, "Select a Planar Face:", True)
Dim reference1 As Reference
Set reference1 = Selection1.Item2(1).Reference
Dim hybridShapeExtract1 As HybridShapeExtract
Set hybridShapeExtract1 = hybridShapeFactory1.AddNewExtract(reference1)

hybridShapeExtract1.PropagationType = 3
hybridShapeExtract1.ComplementaryExtract = False
hybridShapeExtract1.IsFederated = False
hybridBody1.AppendHybridShape hybridShapeExtract1
part1.InWorkObject = hybridShapeExtract1
part1.Update 

Selection1.Clear
Selection1.Add hybridShapeExtract1
CATIA.StartCommand ("Isolate")
part1.Update

End Sub

Regards
Fernando

- Romania
- EU
 
it is working but only when you are working in a nonhybrid part.
I wants to work in hybrid part.
In hybrid part, you can't insert a hybrid body and line Set hybridBody1 = hybridBodies1.Add() gives error.
Is there any idea to deal in hybrid part.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor