Hi All
I am new to CATScript and trying to learn from different forums in internet.
I request an help on the macro below:
Requirement is to create a plane parallel to selected reference plane and point.
Option 1:
My requirement is the new plane created must be created in exiting active GS.
Option 2:
Inform the user about the active GS or Body. Ask the user to selction whether the new plane to be created in existing active GS or to be created in a new GS.
MACRO what I crated is as below and the plane gets created always on the first GS even though the first GS is not active
Sub CATMain()
Set partDocument1 = CATIA.ActiveDocument
Set part1 = partDocument1.Part
Set hybridShapeFactory1 = part1.HybridShapeFactory
Set hybridBodies1 = part1.HybridBodies
'--------Selection 1
Msgbox("Pickup the reference plane for offset")
Dim InputObjectType(0), Status1
Set selection1 = partDocument1.Selection
selection1.Clear
InputObjectType(0)="Plane"
Status1=selection1.SelectElement2(InputObjectType,"Select plane",false)
If Status1 = "Cancel" Then selection1.Clear: Exit Sub
Set reference1 = selection1.Item(1).Reference
MsgBox reference1.Name
'------Selection 2
Msgbox("Pickup the reference point to pass the plane")
InputObjectType(0)="Point"
Status1=selection1.SelectElement2(InputObjectType,"Reference point",false)
If Status1 = "Cancel" Then selection1.Clear: Exit Sub
Set reference2 = selection1.Item(1).Reference
MsgBox reference2.Name
Set hybridShapeFactory1 = part1.HybridShapeFactory
Set hybridBody1 = hybridBodies1.Item("Open_body.1")
Set hybridShapePlaneOffsetPt= hybridShapeFactory1.AddNewPlaneOffsetPt(reference1, reference2)
hybridBody1.AppendHybridShape hybridShapePlaneOffsetPt
part1.InWorkObject = hybridShapePlaneOffsetPt
part1.Update
End Sub
I am new to CATScript and trying to learn from different forums in internet.
I request an help on the macro below:
Requirement is to create a plane parallel to selected reference plane and point.
Option 1:
My requirement is the new plane created must be created in exiting active GS.
Option 2:
Inform the user about the active GS or Body. Ask the user to selction whether the new plane to be created in existing active GS or to be created in a new GS.
MACRO what I crated is as below and the plane gets created always on the first GS even though the first GS is not active
Sub CATMain()
Set partDocument1 = CATIA.ActiveDocument
Set part1 = partDocument1.Part
Set hybridShapeFactory1 = part1.HybridShapeFactory
Set hybridBodies1 = part1.HybridBodies
'--------Selection 1
Msgbox("Pickup the reference plane for offset")
Dim InputObjectType(0), Status1
Set selection1 = partDocument1.Selection
selection1.Clear
InputObjectType(0)="Plane"
Status1=selection1.SelectElement2(InputObjectType,"Select plane",false)
If Status1 = "Cancel" Then selection1.Clear: Exit Sub
Set reference1 = selection1.Item(1).Reference
MsgBox reference1.Name
'------Selection 2
Msgbox("Pickup the reference point to pass the plane")
InputObjectType(0)="Point"
Status1=selection1.SelectElement2(InputObjectType,"Reference point",false)
If Status1 = "Cancel" Then selection1.Clear: Exit Sub
Set reference2 = selection1.Item(1).Reference
MsgBox reference2.Name
Set hybridShapeFactory1 = part1.HybridShapeFactory
Set hybridBody1 = hybridBodies1.Item("Open_body.1")
Set hybridShapePlaneOffsetPt= hybridShapeFactory1.AddNewPlaneOffsetPt(reference1, reference2)
hybridBody1.AppendHybridShape hybridShapePlaneOffsetPt
part1.InWorkObject = hybridShapePlaneOffsetPt
part1.Update
End Sub