Re: Copy / Paste / Rotate several time without redefine object or base point.

Re: Copy / Paste / Rotate several time without redefine object or base point.

m.lharidon
Enthusiast Enthusiast
1,495 Views
7 Replies
Message 1 of 8

Re: Copy / Paste / Rotate several time without redefine object or base point.

m.lharidon
Enthusiast
Enthusiast

Hello,

 

In the "Copy block x time between 2 points (with orientation) (CM2P adaptation)" Topic I discover I can use this fontion (to have the blocks I use alway align with :

 (setq blk_ent (entget (entlast)))
      (entmod (subst (cons 50 rad)(assoc 50 blk_ent)blk_ent))
      (setq e (entlast))
  

I tried to integrate it In the CBPRM Lisp but I have an error "bad DXF group". Here is the lisp:

(defun C:CBPRMB (/ e p); = CopyBase and Paste/Rotate Multiple
  (if
    (and
      (setq e (car (entsel "\Object to Paste/Rotate Multiple times: ")))
      (setq p (cdr (assoc 10 (entget e))))
    ); and
    (progn ; then
      (command "_.copybase" p e "")

      (setq blk_ent (entget (entlast)))
      (entmod (subst (cons 50 rad)(assoc 50 blk_ent)blk_ent))
      (setq e (entlast))
  
      (while (setq p (getpoint "\nPaste base point or <exit>: "))
        (command
          "_.pasteclip" p
          "_.rotate" "_last" "" p pause
        ); command
      ); while
    ); progn
  ); if
  (princ)
)

Can you help me for that?

 

Thanks.

 

ML

0 Likes
Accepted solutions (1)
1,496 Views
7 Replies
Replies (7)
Message 2 of 8

ВeekeeCZ
Consultant
Consultant

I don't really understand how you imagine the workflow, but this issue with your code is that you never set the rad variable.

Elaborate your workflow a bit, where to get the angle from, if you need more help.

 

 


@m.lharidon wrote:

Hello,

 

In the "Copy block x time between 2 points (with orientation) (CM2P adaptation)" Topic I discover I can use this fontion (to have the blocks I use alway align with :

 (setq blk_ent (entget (entlast)))
      (entmod (subst (cons 50 rad)(assoc 50 blk_ent)blk_ent))
      (setq e (entlast))
  

I tried to integrate it In the CBPRM Lisp but I have an error "bad DXF group". Here is the lisp:

(defun C:CBPRMB (/ e p); = CopyBase and Paste/Rotate Multiple
  (if
    (and
      (setq e (car (entsel "\Object to Paste/Rotate Multiple times: ")))
      (setq p (cdr (assoc 10 (entget e))))
    ); and
    (progn ; then
      (command "_.copybase" p e "")

      (setq blk_ent (entget (entlast)))
      (entmod (subst (cons 50 rad)(assoc 50 blk_ent)blk_ent))
      (setq e (entlast))
  
      (while (setq p (getpoint "\nPaste base point or <exit>: "))
        (command
          "_.pasteclip" p
          "_.rotate" "_last" "" p pause
        ); command
      ); while
    ); progn
  ); if
  (princ)
)

Can you help me for that?

 

Thanks.

 

ML


 

0 Likes
Message 3 of 8

dbhunia
Advisor
Advisor

Try like this.......

 

 

(defun C:CBPRMB (/ e p); = CopyBase and Paste/Rotate Multiple
  (if
    (and
      (setq e (car (entsel "\Object to Paste/Rotate Multiple times: ")))
      (setq p (cdr (assoc 10 (entget e))))
    ); and
    (progn ; then
      (command "_.copybase" p e "")

      ;(setq blk_ent (entget (entlast)))
      ;(entmod (subst (cons 50 rad)(assoc 50 blk_ent)blk_ent))
      ;(setq e (entlast))
  
      (while (setq p (getpoint "\nPaste base point or <exit>: "))
        (command
          "_.pasteclip" p
          "_.rotate" "_last" "" p pause
        ); command
      ); while
    ); progn
  ); if
  (princ)
)

Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
0 Likes
Message 4 of 8

m.lharidon
Enthusiast
Enthusiast

Hello,

 

Unfortunatly, the fonction you corrected stays the same at it was before. When I define a block with rotation at x° it keeps x+90°. What i looked for it to always concider the selected block as 0°. then when i copy i give the orientation from 0. (first click past the block, second click orient it where i click. 

 

(attached an exemple to make it clearer).

 

 

 

Thanks for the help.

 

 

0 Likes
Message 5 of 8

dbhunia
Advisor
Advisor
Accepted solution

Try like this.......

 

 

(defun C:CBPRMB (/ e p blk_ent); = CopyBase and Paste/Rotate Multiple
  (if
    (and
      (setq e (car (entsel "\Object to Paste/Rotate Multiple times: ")))
      (setq p (cdr (assoc 10 (entget e))))
    ); and
    (progn ; then
      (command "_.copybase" p e "")
  
      (while (setq p (getpoint "\nPaste base point or <exit>: "))
        (command "_.pasteclip" p)
        (setq blk_ent (entget (entlast)))
        (entmod (subst (cons 50 0.0)(assoc 50 blk_ent)blk_ent))	
        (command "_.rotate" "_last" "" p pause
        ); command
      ); while
    ); progn
  ); if
  (princ)
)

 

 

 


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
0 Likes
Message 6 of 8

ВeekeeCZ
Consultant
Consultant

Here is re-written version of Kent Cooper's idea

- works in UCS

- allows pre-selection

- gives you a previous when placing the block

- has to be finished by ESC pressing (guess the preview worth this little inconvenience)

 

 

(defun C:CBPRMB (/ *error* e p r); = CopyBase and Paste/Rotate Multiple
  
  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end"))
      (princ (strcat "\nError: " errmsg)))
    (princ)
    );end error

  (if (setq e (if (ssget "_I")
                (ssname (ssget) 0)
                (car (entsel "\Object to Paste/Rotate Multiple times: "))))

    (progn ; then
      (setq p (cdr (assoc 10 (entget e))))
      (setq r (getpropertyvalue e "Rotation"))
      (setpropertyvalue e "Rotation" (angle '(0 0 0) (getvar 'UCSXDIR)))
      (command "_.copybase" p e "")
      (setpropertyvalue e "Rotation" r)
      
      (while T
        (command "_.pasteclip" pause
                 "_.rotate" "_last" "" "@" pause))))
  (princ)
  )

 

0 Likes
Message 7 of 8

m.lharidon
Enthusiast
Enthusiast

Thanks a lot tor the feedback

0 Likes
Message 8 of 8

m.lharidon
Enthusiast
Enthusiast

Thanks a lot, this is perfect!!

0 Likes