×
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

Catia Macro Find Axis and Face Coordinates

Catia Macro Find Axis and Face Coordinates

Catia Macro Find Axis and Face Coordinates

(OP)
Hello,

I am looking for a macro to find 2 coordinates of a hole axis and 2 for a face.

I want it to work by running the macro, select axis, msgbox with 2 coordinates, select face, msgbox with 2 coordinates.

Any ideas

Thanks,

RE: Catia Macro Find Axis and Face Coordinates

Hello,

Please be more specific (provide an example) about "coordinates of an axis" and "coordinates of a face". A picture would truly worth a thousand words :)

cilici

RE: Catia Macro Find Axis and Face Coordinates

(OP)
Okay forget the face for now.

Basically I want to have a button to position a cap screw head into the product by selecting a hole axis and a face.

So when assembling a screw as normal you would bring it into the assembly, then snap the central axis of the screw to the central axis of the hole. Then snap the bottom face of the screw to the face you want it to sit on.

Not sure how I could give a picture. Any ideas?

RE: Catia Macro Find Axis and Face Coordinates

what is your code so far and where/what is the problem?

Eric N.
indocti discant et ament meminisse periti

RE: Catia Macro Find Axis and Face Coordinates

(OP)

CODE -->

Sub CATMain()

Dim productDocument1 As ProductDocument
Set productDocument1 = CATIA.ActiveDocument

Dim product1 As Product
Set product1 = productDocument1.Product

Dim products1 As Products
Set products1 = product1.Products

Dim product2 As Product
Set product2 = products1.Item("FIXINGS")

Dim products2 As Products
Set products2 = product2.Products

Dim arrayOfVariantOfBSTR1(0)
arrayOfVariantOfBSTR1(0) = Part Location
Set products2Variant = products2
products2Variant.AddComponentsFromFiles arrayOfVariantOfBSTR1, "All"

Dim documents1 As Documents
Set documents1 = CATIA.Documents

Dim productDocument2 As ProductDocument
Set productDocument2 = documents1.Item(Product to Assemble Into)

Dim product3 As Product
Set product3 = productDocument2.Product

Dim products3 As Products
Set products3 = product3.Products

Dim product4 As Product
Set product4 = products3.Item("M8_SOCKET_CAP_HEAD.1")

Dim move1 As Move
Set move1 = product4.Move

Set move1 = move1.MovableObject

Dim arrayOfVariantOfDouble1(11)
arrayOfVariantOfDouble1(0) = 0#
arrayOfVariantOfDouble1(1) = 0#
arrayOfVariantOfDouble1(2) = 1#
arrayOfVariantOfDouble1(3) = -0#
arrayOfVariantOfDouble1(4) = 1#
arrayOfVariantOfDouble1(5) = -0#
arrayOfVariantOfDouble1(6) = -1#
arrayOfVariantOfDouble1(7) = -0#
arrayOfVariantOfDouble1(8) = 0#
arrayOfVariantOfDouble1(9) = 3262#
arrayOfVariantOfDouble1(10) = -390#
arrayOfVariantOfDouble1(11) = 1526.983066
Set move1Variant = move1
move1Variant.Apply arrayOfVariantOfDouble1

Set move1 = product4.Move

Set move1 = move1.MovableObject

Dim arrayOfVariantOfDouble2(11)
arrayOfVariantOfDouble2(0) = 1#
arrayOfVariantOfDouble2(1) = 0#
arrayOfVariantOfDouble2(2) = 0#
arrayOfVariantOfDouble2(3) = 0#
arrayOfVariantOfDouble2(4) = 1#
arrayOfVariantOfDouble2(5) = 0#
arrayOfVariantOfDouble2(6) = 0#
arrayOfVariantOfDouble2(7) = 0#
arrayOfVariantOfDouble2(8) = 1#
arrayOfVariantOfDouble2(9) = 0#
arrayOfVariantOfDouble2(10) = 0#
arrayOfVariantOfDouble2(11) = 0.616934
Set move1Variant = move1
move1Variant.Apply arrayOfVariantOfDouble2

End Sub 

Thats my code so far. Its pretty much just a recorded macro. I had to take some of the titles out (product and file location) but they are fine in my version. How can I automate this so that I click a line and a feature of the screw goes to there... Really I just need a vector of the axis or 2 points on the axis to be able to get the movement numbers seen above.

How can I do this?

RE: Catia Macro Find Axis and Face Coordinates

you can ask the user to select a cylindrical face, then define a reference out of it. then ask user to select a face and create another reference.

From those 2 ref, get the matrix position for the location of the screw.

in order to get the matrix position you could build and axis based on the intersection of the face and the cylindrical axis...

check this thread560-251808: CATIA Portable Script Center, you might learn from it (like asking user to select face and many other valuable stuff)...

Will come back to you soon

Eric N.
indocti discant et ament meminisse periti

RE: Catia Macro Find Axis and Face Coordinates

(OP)
Had a look through this. Looks very useful.

Unfortunately it does not tell me what I want. I think I am going along the right lines now though...

If I select the top circle and the bottom circle of the hole, create a point in the centre then get the coordinates of the points and do math to work out the direction.

Any better ideas?

RE: Catia Macro Find Axis and Face Coordinates

or you can select the cylindrical face (1 click) and get its axis... which solution you think the user will prefer?

you might also check if something is already selected and if it is a cylindrical face in case the user made the selection first.

But you can go with the 2 circles... it's up to you (in fact 1 circle is enough as a circle is on a plane and the circle axis is normal to the plane...

so did you find in the CPSC how to ask user to select a circle?

Eric N.
indocti discant et ament meminisse periti

RE: Catia Macro Find Axis and Face Coordinates

(OP)
Got it to work with the circles!

2 clicks are needed for direction so circles seems the best way to do it.

Do you know how to get the diameter/radius of a circle from selectelement2?

I got creating a point in the circle then modified it so it doesn't append.

RE: Catia Macro Find Axis and Face Coordinates

check measurable object

Eric N.
indocti discant et ament meminisse periti

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