×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Points and Planes repetition Command in macro

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!

RE: Points and Planes repetition Command in macro

(OP)
The code I get recording this command gives me manual creation of each point.

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

This depends on how you want to create the points, you need to get some references (name of the curve, length, starting point, a.s.o.).

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 Sub 

Regards
Fernando

https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...

RE: Points and Planes repetition Command in macro

Are you in VBA or CATScript/catvbs? You could have the user select the curve and input the number of points they want on the curve, capture the length of the selected curve, place a start point on the curve, place points on the curve, then place normal planes through the points. But as ferdo mentioned, we need to know exactly what you want to do.

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).

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources