(getpropertyvalue block "Rotation") returns 90 or 270 degree when the block is rotated to any value in ZX or ZY plane

(getpropertyvalue block "Rotation") returns 90 or 270 degree when the block is rotated to any value in ZX or ZY plane

ShricharanaB
Advocate Advocate
2,190 Views
25 Replies
Message 1 of 26

(getpropertyvalue block "Rotation") returns 90 or 270 degree when the block is rotated to any value in ZX or ZY plane

ShricharanaB
Advocate
Advocate

Hi, 

 

I'm trying to get the rotation of a block. 

I would need both  angle  in XY plane and angle to XY values to attach some other blocks to this block in proper orientation (think attaching legs to conveyors). Though I could make do with only the angle in XY plane as I would know the angle to XY plane beforehand or I can calculate it from block attributes. 

(getpropertyvalue block "Rotation") or getting assoc of 50  of the block works only when the block is not rotated in the z direction. But if the block is rotated by any value in z direction then they return 90 or 270 depending on z rotation direction.

How can I get the actual rotation of the block in XY plane at least?  

Not rotated in z:

ShricharanaB_0-1672903191834.pngShricharanaB_1-1672903213677.png

ShricharanaB_2-1672903239111.png

 

Rotated in z:

ShricharanaB_4-1672903378856.pngShricharanaB_3-1672903358207.png

ShricharanaB_5-1672903404650.png

 

 

 

 

 

 

0 Likes
Accepted solutions (3)
2,191 Views
25 Replies
Replies (25)
Message 21 of 26

leeminardi
Mentor
Mentor

@john.uhden Excellent suggestion! I'd love to share a brew with you.  Do you know someplace warm?For "visual thinkers" like us (see today's NYT article by Temple Grandin) my post has way more words than I'm comfortable with.  It got even worse for me today when I jumped the gun on this overly terse problem statement. I should have learned by now to get a clear problem definition before I jump in!

lee.minardi
0 Likes
Message 22 of 26

ShricharanaB
Advocate
Advocate

Hi @leeminardi ,

I do apologize for my murky posts.  

I should have been clearer on what I wanted to do. I'll try to be more precise in the future. 

Post #7 - Yes the Y axis of the block will always be parallel to the XY plane.

Post #11 - I do realize now that saying "adding legs to conveyors" in the first post was not at all sufficient. I do mean positive and negative slope of the blocks. 

Post #13 - before this point I was trying to make the code work for a single block. Which I managed to do thanks to all of your answers! At this point I was adding the multiple blocks to a single block as needed them -spacing and all- to that single block and getting the end result I need for a single block - be it in a +ve or -ve slope or parallel to XY plane in all z axis rotations. 

Then I started modifying it to work with multiple blocks and realized nentsel wouldn't work on multiple blocks, and so started looking at how to get the same x_dir, y_dir and z_dir without using nentsel. Lets just say last two days have refreshed my memory of matrices and vectors a lot, though still not enough. And now I have a better understanding of how the entities' location and rotation are handled in AutoCAD. 

When I stated the "need to add legs to the block" in Post #17 - I was clarifying the original post where I said "Adding legs to conveyors"  - to convey what exactly I was trying to do. By which point I had the adding legs at intervals part figured out but needed the X axis of the block angle to XY plane of WCS to calculate the insertion points for the legs and angle of projection of X axis of the block to the X axis of the WCS for the rotation of the block. 

 

And the summary,

1. Inserting multiple blocks positioned along the x axis of the block and to their length - struggling to get the angle (x axis of block to xy plane of WCS) if the block has +ve/-ve slope along x axis. 

spacing and number of instances of which are to be calculated by the code  -  I have this working already.

 

Part about z axis and x axis is correct. - struggling to get the angle (x axis projected onto XY plane to the x axis of WCS). I'm rotating the blocks using Rotate3D.

Currently I'm trying the code written by Gile in Post #18, and will let you know how it goes.

Hope I'm not confusing everything even further with this post.

 

Again, I'm really thankful for all your help and will try to be clearer in the future.

 

0 Likes
Message 23 of 26

leeminardi
Mentor
Mentor

@ShricharanaB You state "...struggling to get the angle (x axis of block to xy plane of WCS) if the block has +ve/-ve slope along x axis. "  We need a clear definition of what you consider an + or - incline.   @_gile post 18 provides a good function for a block's slope angle if the block's Y axis is parallel to the World XY plane but is it in line with your assumed definition of + and -?

leeminardi_1-1673456743689.png

 

 

lee.minardi
0 Likes
Message 24 of 26

_gile
Consultant
Consultant

@leeminardi  a écrit :

@_gile post 18 provides a good function for a block's slope angle if the block's Y axis is parallel to the World XY


No, the snippet I posted works whatever the line orientation.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 25 of 26

leeminardi
Mentor
Mentor

@_gile In the image below the ucs icon shows the WCS.   The red arrow of the block shows its positive x axis.  Your code outputs an angle of -60° for both.  Of course, the sense of the block's x axis for both instances is downward but it wasn't clear what @ShricharanaB wanted to consider a positive slope.  As you know a line (and not a vector) with a positive slope would consider the block on the left as a positive slope.   In my last post I was trying to get @ShricharanaB to clarify how he defined a positive slope.  For a conveyor system going from left to right (in the X direction) I assumed uphill as Z increasing and downhill z decreasing.  Of course, the OP could reorient his conveyor blocks to yield uphill independent of the world WCS. But if he is just tilting a  block that represents a conveyor module as a block,  up or down as needed, the angle may have the wrong sign depending on the sign convention that he is using.

@ShricharanaB it's your call, do both of these blocks indicate a negative slope for your application?  If so, you're all set!

leeminardi_0-1673468866528.png

 

lee.minardi
0 Likes
Message 26 of 26

ShricharanaB
Advocate
Advocate

Hi @leeminardi,

Yes they both indicate a negative slope.

These conveyors will never be add upside down. Considering the top (T) and bottom (b)  of the block as marked below , the crossed out will never be the case. So the the code provided by Gile works very well. 

ShricharanaB_3-1673500051438.png

@_gile I used the code and tested with multiple blocks. It works very well for me. Thank you!

 

 

 

0 Likes