Jump to content

Move TITLE BLOCK from Current location to base point 0,0


hssiway

Recommended Posts

Hi, I have recently started using LISP codes. Here is what I need to do using LISP routine in a existing drawing where title block is in Model space.

 

 

1. Select all

2. Move

3. Specify base point:

4. Specify second point: 0,0

 

 

This will move entire drawing objects and set the lower left corner of title block at 0,0 vortex.

 

 

I have written below LISP routine but it is not working. Can any one help? I want to avoid user prompts

 

 

(defun c:test()

 

(setq X1 (apply 'min (mapcar 'car PointList)))

(setq Y1 (apply 'min (mapcar 'cadr PointList)))

(setq X2 (apply 'max (mapcar 'car PointList)))

(setq X2 (apply 'max (mapcar 'car PointList)))

; (setq LL (getpoint "\nX1 Y1: "))

(setq LL (List X1 Y1))

(setq LR (List X2 Y1))

(setq UR (List X2 Y2))

(setq UL (List X1 Y2))

;(setq newbp (getpoint '(0 0) "New Base Point"))

;(setq sel1 (ssget LL UR))

(command "Move" "all" "" LL '(0 0))

(Princ)

)

 

 

Thanks

hssiway

Link to comment
Share on other sites

First you need to save the current layer state, then turn on, thaw, and unlock all layers. You need to be sure you're moving everything.

Next regen and use (getvar "EXTMIN") for your LL value.

Move All, then reset that layer state.

Link to comment
Share on other sites

A better way is find the title block insertion point and then move everything, relative to 0,0.

 

An example for title blocks in layouts. the title block in the code is lower left as the insert point and moves to 0,0

; move title blocks
; By Alan H
(PROMPT ".....now moving dwgs....")
(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(vlax-for lay (vla-get-Layouts doc)
 (setq plotabs (cons (vla-get-name lay) plotabs))
)
(setq plottablist (acad_strlsort plotabs))
(setq len (length plottablist))
(setq oldsnap (getvar "osmode")) 
(setvar "osmode" 0)
(setq en (entsel "Pick Title Block:"))
(setq K 0)
(repeat len
 (setq name (nth K plottablist))
 (princ name)
 (if (/= name "Model")
   (progn
   (setvar "ctab" name)
   (setq minxy  (getvar "extmin"))
   (setq maxxy (getvar "extmax"))
   (setq  ed (entget (car en)))
   (setq ss (ssget "_X" (list (cons 0 "INSERT")  (cons 410 name) (cons 2 (cdr (assoc 2 ed))) ) ))
   (setq n (sslength ss))
   (setq en (ssname ss 0))
   (setq xy (assoc 10 (entget en)))
 ; insertion pt   (setq xy (assoc 10 el)) 
   (setq xy (list (cadr xy)(caddr xy)))
   (command "move" "w" minxy maxxy  "" xy "0,0")
   (command "zoom" "E")
   ) ;end progn
) ; end if
(setq K (+ K 1))
(princ k)
(setq ss '()
       xy nil)
) ; end repeat

(setvar "osmode" oldsnap)
(princ)

Link to comment
Share on other sites

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...