Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations pierreick on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro to create an Isometric View on a CATDrawing

Status
Not open for further replies.

jerry331

Automotive
Oct 14, 2022
5
thread560-419177
regarding the the macro from cstark works very well for generic iso view creatation.

But this view calculation of cross product vector wont work with the assembly components that has orientation defined in the assembly.
If we want to create the iso view of a components from the assembly, the view calcuation of cross product vector wont fit. Is there any way to add the component orientation to the macro to calculate cross product vector?

Thanks
 
Replies continue below

Recommended for you

Product.Position.GetComponents retrieves product's position and orientation
 
Yes I can get that one, but how this and the viewpoint information can be tranfer to the vector that drawingViewGenerativeBehavior1.DefineIsometricView use?
 
Here is the code i am working on, this is to process all the components of an assembly and projected the current view in 3D to the drawing.

This works well on the parts which has not position orientation in the assembly, but for the components that has position orientation(rotated) in the assembly, the view projected to 2D is not the view in 3D.
so this code did not considered the components transform in the assembly, but catia do need this information for odrawingViewGenerativeBehavior.DefineIsometricView function.

I am looking for the way to calclate the vector.

 
 https://files.engineering.com/getfile.aspx?folder=24c3a7bc-bfb0-4b29-ad63-1d95511b1aad&file=Project_assembly_instance_iso.CATScript
finally with the help of ChatGPT I got this solved, to consider the assembly instace orientation to project iso view individually from the assembly inside, here is the caclculatuion needed to transfer the up and site vector

' Get the position of the product
Dim pos(11)
oInProduct.Position.GetComponents pos

' Extract the x, y, and z components of the position vector
Dim posVector(2)
posVector(0) = pos(0)
posVector(1) = pos(1)
posVector(2) = pos(2)

' Calculate the rotation matrix for the product orientation
Dim rotMatrix(2, 2)
rotMatrix(0, 0) = pos(3)
rotMatrix(0, 1) = pos(4)
rotMatrix(0, 2) = pos(5)
rotMatrix(1, 0) = pos(6)
rotMatrix(1, 1) = pos(7)
rotMatrix(1, 2) = pos(8)
rotMatrix(2, 0) = pos(9)
rotMatrix(2, 1) = pos(10)
rotMatrix(2, 2) = pos(11)

' Rotate the initial up and sight vectors using the rotation matrix
Dim up(2)
up(0) = rotMatrix(0, 0) * initialUp(0) + rotMatrix(0, 1) * initialUp(1) + rotMatrix(0, 2) * initialUp(2)
up(1) = rotMatrix(1, 0) * initialUp(0) + rotMatrix(1, 1) * initialUp(1) + rotMatrix(1, 2) * initialUp(2)
up(2) = rotMatrix(2, 0) * initialUp(0) + rotMatrix(2, 1) * initialUp(1) + rotMatrix(2, 2) * initialUp(2)

Dim sight(2)
sight(0) = rotMatrix(0, 0) * initialSight(0) + rotMatrix(0, 1) * initialSight(1) + rotMatrix(0, 2) * initialSight(2)
sight(1) = rotMatrix(1, 0) * initialSight(0) + rotMatrix(1, 1) * initialSight(1) + rotMatrix(1, 2) * initialSight(2)
sight(2) = rotMatrix(2, 0) * initialSight(0) + rotMatrix(2, 1) * initialSight(1) + rotMatrix(2, 2) * initialSight(2)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor