Lisp for dynamic block - rotate action

yu85.info
Advocate

Lisp for dynamic block - rotate action

yu85.info
Advocate
Advocate

Hi, I have this DWG attached .I need to make this drawing a block that some objects can be rotated (from A to B). This is just an example the actual drawing is more complex.

Is there a way to create a lisp routine so at first I will choose the elements i need to be with a rotate parameter and then the entire drawing and the result B will come up?

Thanks you very much for your help

 

0 Likes
Reply
Accepted solutions (1)
1,463 Views
23 Replies
Replies (23)

Moshe-A
Mentor
Mentor

@yu85.info ,

 

We could take all objects from the model space and assign only the yellows for the dynamic rotate (are you aware that we are talking only on objects that are set yellow by Object and not from yellow Layer)

is there any change that a yellow objects will exist in model space that are not to be assigned to dynamic rotate?

 

Moshe

 

yu85.info
Advocate
Advocate

- We could take all objects from the model space and assign only the yellows for the dynamic rotate - 

Good... but...

 

- are you aware that we are talking only on objects that are set yellow by Object and not from yellow Layer - 

 

The yellow color was just for the example so I can explain that I need just some of the objects and not all. actually I need the lisp to work on any objects selected regardless their color to layer.

The ideal way is to take all the objects from the model space and assign only the selected objects for the dynamic rotate.

0 Likes

Moshe-A
Mentor
Mentor
Accepted solution

@yu85.info  shalom,

 

tell you the truth, i am not really understand what is your goal.

and why the 'hetz zaphone' is needed, this not mapa 😀

 

anyway i think this is solved

 

enjoy

Moshe

 

 

(defun c:WrapDynBlk (/ getBlockName ; local function
		       bname r0 ss0 ss1 bname)

 (defun getBlockName (/ flag name)

  (while (not flag) 
   (setq name (getstring t "\nBlock name: ")) 

   (cond
    ((eq name "")
     (setq flag t)
      name
    ); case
    ((tblsearch "block" name)
     (princ (strcat "\nBlock \"" name "\" is already exist."))
    ); case
    ( t
     (setq flag t)
    ); case
   ); cond
  ); while
   
  name 
 ); getBlockName


 ; here start c:WrapDynBlk
 (setvar "cmdecho" 0)
 (command "._undo" "_begin")
  
 (if (and
       (/= (setq bname (getBlockName)) "")
       (setq r0 (getpoint "\nRotation base point: "))
       (setq ss0 (ssget))
     )
  (progn
   (command "._copybase" "0,0" "_si" ss0)
   (command "._erase" "_si" ss0)
   (command "._block" bname "0,0" "_si" "_all")
   (command "._bedit" bname)
   
   (setq ename (entlast))
   (command "._pasteclip" "0,0")

   (setq ss1 (ssadd))
   (while (setq ename (entnext ename))
    (ssadd ename ss1)
   ); while

   (command "._bparameter" "_rotation" r0 0.5 "" "" "")
   (command "._bactiontool" "_rotate" (polar r0 (/ pi 4) 0.5)"_si" ss1)
   (command "._bclose" "_save")
   (command "._insert" bname "0,0" 1 1 0)
  ); progn 
 ); if

 (command "._undo" "_end")
 (setvar "cmdecho" 1)

 (princ "\nDone.")
 (princ)
); c:WrapDynBlk

 

 

yu85.info
Advocate
Advocate

OMG! hallelujah! 

TODA RABA

Works wonderfully

0 Likes