Jump to content

Recommended Posts

Posted

I don't think so - but maybe this would work (I have made it so that it collects objects from all spaces (I don't think this is an issue, but worth a try).

Also, it sets the UCS after filtering the set.

 

(defun c:yellowr  (/ oldosn ss)
 (setq oldosn (getvar "osmode"))
 (setvar "osmode" 0)
 (command "UCS" "W")
 (if (setq ss (ssget "X" (list (cons 0 "INSERT"))))
   (progn
     (foreach ent  (mapcar 'cadr (ssnamex ss))
       (if (not (< (cadddr (assoc 10 (entget ent))) -10))
         (ssdel ent ss)))
     (if (not (zerop (sslength ss)))
       (progn
         (ucs-sel "yellow")
       (repeat 9
         (command "_rotate" ss "" '(0 0 0) -10)))))
   (princ "\n<!> No Blocks Found <!>"))
 (setvar "osmode" oldosn)
 (princ))

(defun c:redr  (/ oldosn ss)
 (setq oldosn (getvar "osmode"))
 (setvar "osmode" 0)
 (command "UCS" "W")
 (if (setq ss (ssget "X" (list (cons 0 "INSERT"))))
   (progn      
     (foreach ent  (mapcar 'cadr (ssnamex ss))
       (if (not (< (caddr (assoc 10 (entget ent))) -10))
         (ssdel ent ss)))
     (if (not (zerop (sslength ss)))
       (progn
         (ucs-sel "red")
       (repeat 9
         (command "_rotate" ss "" '(0 0 0) -10)))))
   (princ "\n<!> No Blocks Found <!>"))
 (setvar "osmode" oldosn)
 (princ))

(defun ucs-sel  (col)
 (COMMAND "UCS" "NAMED" "R" col))

  • Replies 33
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    16

  • Stermaj

    16

  • SEANT

    2

Posted

I tried debugging by running (entget (car (entsel))) and selecting random blocks. I discovered that the coordinates for a block after a rotation are:

 

Select object: ((-1 . ) (0 . "INSERT") (330 .

name: 7ef05cf8>) (5 . "564") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 .

"Side") (62 . 0) (100 . "AcDbBlockReference") (2 . "OR") (10 -27.15 1.2568e-013

27.15) (41 . 1.0) (42 . 1.0) (43 . 1.0) (50 . 4.71239) (70 . 0) (71 . 0) (44 .

0.0) (45 . 0.0) (210 1.0 0.0 3.60822e-016))

 

Now the block i selected was originally at 0,-27.15, 27.15, and it was rotated to 27.15,-27.15,0. For some reason, autocad seems to not think the block is at either location. The coordinates autocad reads now for the block are relative to the rotation of the reducs, but positionally relative to the WCS. I have no idea why this would be the case, but this would be why the later rotation steps fail.

Posted

Is there a way to use autolisp to select all objects intersecting a plane? if so, can i just input 6 planes to intersect each face and have that be the criteria to do the rotations instead?

Posted

I'm not sure about selecting objects that intersect a plane - but, the

 

1.2568e-013

 

is just AutoCADs way of saying zero, so the block has been rotated from:

 

0,-27.15, 27.15

 

to

 

-27.15, 0, 27.15

 

The points listed in the DXF tables are ALWAYS in WCS.

Posted

Even with accounting for 1.2568e-013 being 0, the entget function still reads

-27.15 .2568e-013 27.15 even though the block is at 27.15,-27.15,0. The XYZ coordinates are mixed up, the actual z position is 0, while autocad thinks its 27.15, the y position is -27.15 but autocad thinks its 0, and the x is listed at -27.15 instead of +27.15

Posted

Are you sure that the position you are seeing isn't a UCS position, whereas the position that (entget) reads is WCS?

Posted

Yes. I reset the UCS to the WCS to try to see if that was the case. the lisp program works as it should, but autocad for some reason is reporting the wrong locations for these blocks. Im going to try it on another computer to see if its a local problem or not.

Posted

It was the same on the other computer. I decided to redo the whole code and instantly set the view to a side view, then run

 

ssget "w" with coordinates to select a box that encompasses a side, then flip back to the original view and then perform the rotation there. Its simpler but for a split second you see the screen change views. Thanks again though for all your help!

-Jon

 

(defun c:greenr (/ oldosn)

(setq oldosn (getvar "osmode"))

(setvar "osmode" 0)

(COMMAND "UCS" "W")

(COMMAND "-view" "S" "tempview")

(COMMAND "-view" "O" "Front")

(setq ss (ssget "C" '(-20 0 30) '(-30 0 -30)))

(COMMAND "-view" "Restore" "tempview")

(c:greenucs)

(repeat 18

(COMMAND "_rotate" ss "" '(0 0 0) -5)

)

(COMMAND "UCS" "W")

(setvar "osmode" oldosn)

(princ)

)

Posted

yeah, me too. Thanks again though for all your time.

Posted

For what it’s worth, some objects (e.g., Inserts, LightWeightPolylines) maintain their own Object Coordinate System (OCS). This coordinate system is not (necessarily) based on either the WCS or current UCS but derived from the objects Extrusion Direction (Normal, or Group code 210). For more information search the DXF Reference for “Arbitrary Axis Algorithm”.

 

Queries to these objects will be return coordinates based on this OCS. These can be translated to either WCS or UCS with the trans function or ThisDrawing.Utility.TranslateCoordinates method in VBA.

Posted

Ahh I see, thanks Sean - so I suppose its worth trying this then:

 


(defun c:yellowr  (/ oldosn ss)
 (setq oldosn (getvar "osmode"))
 (setvar "osmode" 0)
 (command "UCS" "W")
 (if (setq ss (ssget "X" (list (cons 0 "INSERT"))))
   (progn
     (foreach ent  (mapcar 'cadr (ssnamex ss))
       (if (not (< (caddr ([color=Blue][b]trans[/b][/color] (cdr (assoc 10 (entget ent))) [color=Blue][b]2 0[/b][/color])) -10))
         (ssdel ent ss)))
     (if (not (zerop (sslength ss)))
       (progn
         (ucs-sel "yellow")
         (repeat 9
           (command "_rotate" ss "" '(0 0 0) -10)))))
   (princ "\n<!> No Blocks Found <!>"))
 (setvar "osmode" oldosn)
 (princ))

(defun c:redr  (/ oldosn ss)
 (setq oldosn (getvar "osmode"))
 (setvar "osmode" 0)
 (command "UCS" "W")
 (if (setq ss (ssget "X" (list (cons 0 "INSERT"))))
   (progn
     (foreach ent  (mapcar 'cadr (ssnamex ss))
       (if (not (< (cadr ([b][color=Blue]trans[/color][/b] (cdr (assoc 10 (entget ent))) [color=Blue][b]2 0[/b][/color])) -10))
         (ssdel ent ss)))
     (if (not (zerop (sslength ss)))
       (progn
         (ucs-sel "red")
         (repeat 9
           (command "_rotate" ss "" '(0 0 0) -10)))))
   (princ "\n<!> No Blocks Found <!>"))
 (setvar "osmode" oldosn)
 (princ))

(defun ucs-sel  (col)
 (COMMAND "UCS" "NAMED" "R" col))



Posted
Ahh I see, thanks Sean - so I suppose its worth trying this then:

 

It could be. . . . I'd have to be quite a bit more familiar with Lisp to say for certain. :unsure:

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...