Hello everyone!
I have this 3d acad drawing that has random blocks rotated on x or y axis (different angles) with different z elevations. These blocks becomes a pain when I want to bring all their elevetions to zero because of their rotation. Is there a lisp that can select these blocks (blk01, blk02, blk03) and put all their rotation to zero? they're not rotated in 2d as in z aixs.....they're rotated in 3d using 3drotate. I need them to be like dead flat on the leveled ground but cant use flatten command either coz I need these in 3d. Please help! Thanks in advance
JC,
trying to figure out what's the orbit course the blocks were made plus if they were inserted in different ucs's would be a headache
instead what about just replacing them with new insert positioned in WCS at zero angle transfering their insertion point to wcs?
try this:
(defun c:blkrpl (/ 3d->2d ; local function ss i ename elist lay bname p0 p1 sx sy) (defun 3d->2d (/ pt) (setq pt (trans p0 1 0)) (list (car pt) (cadr pt)) ) (command ".undo" "begin") (if (setq ss (ssget ":L" (list '(0 . "insert") '(2 . "blk*")))) (progn (command ".ucs" "w" "plan" "") (setq i -1) (repeat (sslength ss) (setq i (1+ i) ename (ssname ss i) elist (entget ename)) (setq lay (cdr (assoc '8 elist))) (setq bname (cdr (assoc '2 elist))) (setq p0 (cdr (assoc '10 elist))) (setq sx (cdr (assoc '41 elist))) (setq sy (cdr (assoc '42 elist))) (setvar "clayer" lay) (command ".-insert" bname (3d->2d) "x" sx sy sx 0) (entdel ename) ); repeat (command "regenauto" "on") (command ".zoom" "extents") ); progn ); if (command ".undo" "end") (princ) )
1. type BLKRPL to run the lisp (after loading it)
2. you manually select each block or use All the select them all
3. the command ignores blocks that are on locked layers
4. the command starts by setting the ucs to world and end with zoom extents
5. if you do not like the outcome just enter U
if your blocks contains attributes? this may need modification but you could ignore attributes by manually setting ATTDIA to 0 + ATTREQ to 0
cheers
moshe
Hello Moshe, Thanks for the reply
I tried your routine and seems that it cant find the blocks, it stuck at "select objects:" all the blocks are dynamic blocks and it has several attributes and parameters. I do agree that reinserting the blocks is the best way to fix the rotation problem but it also needs to copy over attribute values and parameters specially visibility states.
I have succesfuly loaded the vlx and tried on the attached drawing but still cant select the "simple" blocks.
perhaps you can as easily modify this routine from Lee (hope you dont mind Lee). This works perfect in both simple and dynamic blocks exept it reinsert the blocks in 0,0,0
I need the blocks reinserted as the original coordinates (stay in the same exact place) for each block and copy over all attributes and parameter settings including visibility.
JC,
Are you aware of all the information you gave me so far?
where are blk01,blk02,blk03 block name gone?
where are the dynamic blocks?
where are the attributes?
the lisp i send you is design to handle exactly as you requested
now you are sending simple blocks? Are you kidding me?
Moshe
My bad! I forgot about the block names....my apologies! That explains why its not recognizing the blocks I just made for testing purposes.
I tested the first code you sent and it does work....but doesnt retain the blocks in the same coordinates.
OK i accept your apologies
ofcourse they do not retain their origin point cause you want them to be this:
'I need them to be like dead flat on the leveled ground'
a translation each of them from different UCS to WCS at zero angle might put them in different relative position to each other.
moshe
Thanks Moshe!
sorry.....Let rephrase that
These blocks needs to be reinserted to same xyz insertion point to fix the rotation problem and copy over attributes, parameter settings and specially visibilty.
wonder if this ensure's me that is the last version?
Anyhow i also open it to any block name (it's only depand on your selection)
Attributes are taking care!
what do you mean by: parameter settings and specially visibilty?
if you are talking about dynamic blocks with a parameter "Visibility" than this lisp will respond to that
if you are talking about something else or the parameter does not named "Visibility"? then it won't work.
Moshe