Any object in 3D space has three axes of rotation, I want to get these with VBA.

Any object in 3D space has three axes of rotation, I want to get these with VBA.

kasperwuyts
Collaborator Collaborator
1,224 Views
2 Replies
Message 1 of 3

Any object in 3D space has three axes of rotation, I want to get these with VBA.

kasperwuyts
Collaborator
Collaborator
Hello Any object in 3D space has 6 degrees of freedom: -3 position coordinates. -3 axes of rotation. Pitch, tilt, and yaw in aircraft terms. Coordinates are easy to get.But I can only get one rotation property. Is there a way to get all of them? I want to generate a list with the exact positioning of all blocks in one drawing so I can export everything to another 3D modelling tool. Thank you.

Best regards
Kasper Wuyts
_______________________________________________________________________________
If this post solves your problem, clicking the 'accept as solution' button would be greatly appreciated.
0 Likes
1,225 Views
2 Replies
Replies (2)
Message 2 of 3

leeminardi
Mentor
Mentor

I do not know how to do this in AutoCAD VBA but here's how to do it in VLISP.

 

The following code will create a command named blockmatrix which will ouput a 4 x 3 transformation matrix of  the selected block.  The first 3 numbers is the unit vector in the x direction, the 2nd three numbers is the unit vector in the y direction, and the next row is the z direction The 4th set of 3 numbers if the location of the block.  All values are in WCS.

 

A sample output would like like:

Command: BLOCKMATIX
Select Block
Block matrix = ((-0.289658 -0.95713 0.0) (-0.952284 0.288191 0.100499) (-0.0961904 0.0291102 -0.994937) (145.66 125.02 45.906))

 

(defun c:blockmatix (/)
  (setq block_DATA (nentsel "\nSelect Block"))
  (setq block_MATRIX (nth 2 block_DATA))
  (princ "\nBlock matrix = ")
  (princ block_MATRIX)
  (princ)
)

 There are several functions in VLISP that make working with vectors and matrices much easier than with VBA.

lee.minardi
0 Likes
Message 3 of 3

Anonymous
Not applicable

Hi,

 

Sorry if I've misunderstood your query but it looks similar to something I've been doing.

 

The MASSPROP command returns the centroid coordinates of an object (its center of mass) and its principal axes (which are the axes about which it has no product moments of inertia). I think the principal axes could be what you're looking for as the axes of rotation, and the MASSPROP command will give you their direction as a unit vector.

 

Hope this helps,

Tom

0 Likes