Author Topic: update rotated points?  (Read 2765 times)

0 Members and 1 Guest are viewing this topic.

jorgen

  • Guest
update rotated points?
« on: January 09, 2005, 10:07:46 PM »
Lets say I create a box:
Code: [Select]

(command ".pline" p1 p2 p3 p4 "close" )  ;;box
(setq ssbox (ssget "L"))                 ;;save selection-set for rotation    

Now, I know the XYZ vals of all these vertices going in.
So now I rotate the box by some angle:
Code: [Select]

(command ".rotate" ssbox  "" rpoint rotang)

How do I get the updated vals for the rotated points?
I still have the entity returned by ssget(), is there a way to query the entity to find it's current vertices after rotation?

Thanks

SMadsen

  • Guest
update rotated points?
« Reply #1 on: January 10, 2005, 09:22:27 AM »
If the pline got created and rotated succesfully - i.e. if ssbox contains the correct object - you can retrieve it with SSNAME and then walk through its entity data to pick up the vertices. For example,

(setq ent (ssname ssbox 0))
(setq vertices (getPlineVertices (entget ent)))

, where getPlineVertices could be a function like this (provided that the pline is not an oldstyle polyline):
Code: [Select]
(defun getPlineVertices (elist / vlst)
  (foreach n elist
    (cond ((= (car n) 10)(setq vlst (cons (cdr n) vlst))))
  )
  (reverse vlst)
)

whdjr

  • Guest
update rotated points?
« Reply #2 on: January 10, 2005, 09:49:32 AM »
Stig,

Just a question for myself.
Will the variable value for the selection set update if it is gathered before the rotation happens?

SMadsen

  • Guest
update rotated points?
« Reply #3 on: January 10, 2005, 10:07:53 AM »
Will, the selection set merely holds pointers to the objects in the selection. These pointers stay constant until you redefine the selection set. However, editing the objects doesn't effect their addresses - only the data referenced by the addresses (unless you do something to make copies and want to access the copied entities, of course).

Accessing the data after editing the objects will therefore access the updated data.

jorgen

  • Guest
update rotated points?
« Reply #4 on: January 10, 2005, 10:17:32 AM »
Thanks so much smadsen.

I'll try it out and see what happens.

@whdjr :  Yes, the selection-set is valid after rotation (the entity hasn't changed, just it's vertex data).

I actually have several entities rotating in a while() loop, subsequent iterations using the same ssbox entity(ies) all succeed without a hitch.

All this is for is to replace an item fellow detailers at work are now using blocks for, this routine draws everything procedurally with parameters gathered at the comand line and does away with hand-edits, blocks etc.

Thanks again, very kind of you to take the time to help.

whdjr

  • Guest
update rotated points?
« Reply #5 on: January 10, 2005, 11:08:14 AM »
Cool.

That nice to know.