Points and Planes repetition Command in macro
Points and Planes repetition Command in macro
(OP)
Hey Guys!
Just wondering if anyone knows how to access the points and plane command (GSD), thru VBA. Alternatively, does anyone have an effective way of mass point creation on specified curves?
I need to make these points in a macro because further modifications will be made to the points by the script. This macro will be creating 1000+ points in a part document.
Thanks!
Just wondering if anyone knows how to access the points and plane command (GSD), thru VBA. Alternatively, does anyone have an effective way of mass point creation on specified curves?
I need to make these points in a macro because further modifications will be made to the points by the script. This macro will be creating 1000+ points in a part document.
Thanks!





RE: Points and Planes repetition Command in macro
Recording a macro works for me to give some ideas.
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: Points and Planes repetition Command in macro
Can I loop the creation instead? If so how do I add points to an array in a way that allows me to access them as individual objects?
The code below is a snippet of the recording, each point is created individually on the curve. Does you record offer ONE command to do this?
Thanks,
Peter
CODE:
....
Dim hybridShapePointOnCurve1 As HybridShapePointOnCurve
Set hybridShapePointOnCurve1 = hybridShapes1.Item("Point.1")
Dim reference2 As Reference
Set reference2 = part1.CreateReferenceFromObject(hybridShapePointOnCurve1)
Dim hybridShapeFactory1 As HybridShapeFactory
Set hybridShapeFactory1 = part1.HybridShapeFactory
Dim hybridShapePointOnCurve2 As HybridShapePointOnCurve
Set hybridShapePointOnCurve2 = hybridShapeFactory1.AddNewPointOnCurveWithReferenceFromDistance(reference1, reference2, 0#, False)
hybridShapePointOnCurve2.DistanceType = 1
hybridBody1.AppendHybridShape hybridShapePointOnCurve2
part1.InWorkObject = hybridShapePointOnCurve2
part1.Update
Dim parameters1 As Parameters
Set parameters1 = part1.Parameters
Dim length1 As Length
Set length1 = parameters1.Item("Point\Length")
....
RE: Points and Planes repetition Command in macro
Bellow is a code just to get the references name and length of the curve (what is commented is from an older macro, how to create a number of offset planes)
CODE --> CATScript
Language="VBSCRIPT" Sub CATMain() Dim partDocument1 As Document Set partDocument1 = CATIA.ActiveDocument Dim part1 As Part Set part1 = partDocument1.Part Dim hybridBodies1 As HybridBodies Set hybridBodies1 = part1.HybridBodies Dim hybridBody1 As HybridBody Set hybridBody1 = hybridBodies1.Add() Dim hybridShapeFactory1 As Factory Set hybridShapeFactory1 = part1.HybridShapeFactory Dim axisSystems1 As AxisSystems Set axisSystems1 = part1.AxisSystems Dim InputObjectType(0) Set Document = CATIA.ActiveDocument Set Selection = Document.Selection 'We propose to the user that he select a curve InputObjectType(0)="MonoDim" Status=Selection.SelectElement2(InputObjectType,"Select a curve",true) if (Status = "cancel") then Exit Sub Set Curve = Selection.Item(1).Value MsgBox Curve.name Set FirstCurve = Selection.Item(1).Reference Dim mySPA Set mySPA = Document.GetWorkbench("SPAWorkbench") Set mymeasurable = mySPA.GetMeasurable(FirstCurve) MsgBox mymeasurable.length '~ Dim axisSystem1 As AxisSystem '~ Set axisSystem1 = axisSystems1.Item("Absolute Axis System") '~ For j = 30 to 600 step 30 'added '~ Dim reference1 As Reference '~ Set reference1 = part1.CreateReferenceFromBRepName("RSur:(Face:(Brp:(AxisSystem.1;1);None:();Cf11:());WithPermanentBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)", axisSystem1) '~ Dim hybridShapePlaneOffset1 As HybridShapePlaneOffset '~ Set hybridShapePlaneOffset1 = hybridShapeFactory1.AddNewPlaneOffset(reference1, j, False) '~ hybridBody1.AppendHybridShape hybridShapePlaneOffset1 '~ part1.InWorkObject = hybridShapePlaneOffset1 '~ Next 'added '~ For j = 30 to 600 step 30 'added '~ Dim reference2 As Reference '~ Set reference2 = part1.CreateReferenceFromBRepName("RSur:(Face:(Brp:(AxisSystem.1;3);None:();Cf11:());WithPermanentBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)", axisSystem1) '~ Dim hybridShapePlaneOffset2 As HybridShapePlaneOffset '~ Set hybridShapePlaneOffset2 = hybridShapeFactory1.AddNewPlaneOffset(reference2, j, False) '~ hybridBody1.AppendHybridShape hybridShapePlaneOffset2 '~ part1.InWorkObject = hybridShapePlaneOffset2 '~ Next 'added '~ part1.Update '~ ' --- Screen "Fit all" '~ Set specsAndGeomWindow1 = CATIA.ActiveWindow '~ Set viewer3D1 = specsAndGeomWindow1.ActiveViewer '~ viewer3D1.Reframe '~ Set viewpoint3D1 = viewer3D1.Viewpoint3D End SubRegards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: Points and Planes repetition Command in macro
Other things you will likely need to do are check if the person entered an integer for the number of points and check if the points are traveling down the curve (sometimes the can be a along a curve but they go the wrong direction and float in space).