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,
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
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
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
indocti discant et ament meminisse periti
RE: Catia Macro Find Axis and Face Coordinates
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 SubThats 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
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
indocti discant et ament meminisse periti
RE: Catia Macro Find Axis and Face Coordinates
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
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?
indocti discant et ament meminisse periti
RE: Catia Macro Find Axis and Face Coordinates
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
indocti discant et ament meminisse periti