Let’s Start Programming! Forums CATIA Macro Programming Distance between two points

This topic contains 5 replies, has 2 voices, and was last updated by  lal 2 years, 9 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1517

    lal
    Participant

    Hi, I have bought the book of Emmett Ross and even if the book is great, I can’t find what is the problem in my script.

    In chapter 9 page 117, It is explained how to measure the distance between two points. But I can’t have a result.

    here is the script:

    Dim oParameters As Parameters
    Set oParameters = Part1.Parameters

    Dim oDistance As Parameter
    Set oDistance = oParameters.CreateDimension(“Distance”,”LENGTH”, 0)

    Dim oDistanceRel As Relation
    Set oDistanceRel = Part1.Relations.CreateFormula(“DistanceForm”, “”, Largeur, “distance(Geometrical Set.1\X1,Geometrical Set.1\X2)”)

    MsgBox “The endpoints are ” & largeur.ValueAsString & ” apart.”

    It is said that my problem is “part1.Relations.CreateFormula”

    Do you have any idea ?

    #1518

    Emmett Ross
    Keymaster

    HI. Sorry for the confusion, I will have to clean up that section of the book in the next version.Please see the code below. The attached picture also shows how it should look. Try it and let me know.

    #1520

    lal
    Participant

    Thank you, does it work with a plan (XY for instance) and a single point since I would like the distance between a point and his own orthogonal projection on a plan

    #1521

    Emmett Ross
    Keymaster

    Yes, you can modify to code to measure between a point and a plane.Edit this line:

    Set formula1 = relations1.CreateFormula(“Formula.2”, “”, length1, “distance(‘Geometrical Set.1\MyEndPt1′ ,’Geometrical Set.1\MyEndPt2’) “)

    #1537

    Emmett Ross
    Keymaster
    #1539

    lal
    Participant

    Thank you so much, that is pretty clear now ! 🙂

Viewing 6 posts - 1 through 6 (of 6 total)

The forum ‘CATIA Macro Programming’ is closed to new topics and replies.