Andrew1979 Posted May 25, 2015 Posted May 25, 2015 I am trying to get the insertion point of a block on a particular layout tab in paper space. I have searched and tried many things but can't seem to get it to work. I will have a titleblock block on different layouts all called TitleBlock. But I need the insertion point of each block on the different layouts as some people move them around and they aren't located as they should be. Any ideas? Thanks Quote
pBe Posted May 25, 2015 Posted May 25, 2015 ...But I need the insertion point of each block on the different layouts as some people move them around and they aren't located as they should be... Then move the TitleBlock to where it should be? Quote
Andrew1979 Posted May 25, 2015 Author Posted May 25, 2015 I don't actually want to move the title block. I need to know its position on each layout though for another lisp routine to place certain things properly Quote
Lee Mac Posted May 25, 2015 Posted May 25, 2015 Use an appropriate ssget filter, e.g.: (ssget "_X" '((0 . "INSERT") (66 . 1) (2 . "YourBlockName") (410 . "YourLayout"))) If a valid selection set is returned, iterate over the selection set and retrieve the value of DXF group 10 for each entity. Quote
Andrew1979 Posted May 25, 2015 Author Posted May 25, 2015 Use an appropriate ssget filter, e.g.:(ssget "_X" '((0 . "INSERT") (66 . 1) (2 . "YourBlockName") (410 . "YourLayout"))) If a valid selection set is returned, iterate over the selection set and retrieve the value of DXF group 10 for each entity. Thanks Lee. I sort of had something along those lines as what you put in the code. That bit seems to work well. I can't seem to extract any data out of the entity though. I have tried so many different variations, even tried to break each variable definition down to basics to try and pinpoint where I am going wrong ;What i have that works (Setq aaa (ssget "_x" (list (cons 0 "INSERT") (cons 2 "Title Block") (cons 66 1)(cons 410 (getvar "CTAB"))) )) ;And I have tried to get assoc 10 with no luck (setq ent1 (entlast)) (setq ent2 (entget ent1)) (setq ins (assoc 10 ent2)) I can with some messing around get something from the assoc. But ususally with the number 10 at the beginning So if I get the program to run, and then type !ins at the command prompt, get something like: (10 19566.1 3142.81 0.0) Not sure what the problem is there. Any ideas? Thanks Quote
Lee Mac Posted May 25, 2015 Posted May 25, 2015 Note that entlast will simply return the last visible primary entity in the drawing database, it does not relate to the selection set you are retrieving using ssget. You will need to retrieve the entities within the selection set using the ssname function; you may find my tutorial on Selection Set Processing useful in this respect. Here is a quick example showing how to obtain the insertion point of the first entity in the set: (if (setq sel (ssget "_X" (list '(0 . "INSERT") '(2 . "Title Block") '(66 . 1) (cons 410 (getvar 'ctab))))) (setq ins (cdr (assoc 10 (entget (ssname sel 0))))) ) Quote
Andrew1979 Posted May 25, 2015 Author Posted May 25, 2015 I cannot thank you enough for this, works as I need. I have spent so much time fiddling around trying to work this out. I will have a look at your tutorial later. I already am using a pop up box bit of code you wrote which works well too Thanks again, really appreciate your input and expertise. Quote
Lee Mac Posted May 25, 2015 Posted May 25, 2015 You're most welcome Andrew, I'm glad you find the examples helpful. Cheers, Lee Quote
BIGAL Posted May 26, 2015 Posted May 26, 2015 I agree with Pbe just move all your titleblocks in one go back to a reference point, here is some code for you. ; moves all objects in pspace to 0,0 alignment (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 ed (entget (car en))) (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 ss (ssget "_X" (list (cons 0 "INSERT") (cons 410 name) (cons 2 (cdr (assoc 2 ed))) ) )) (setq ss (ssget "_X" (list (cons 0 "INSERT") (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 nil) (setq xy nil) ) ; end repeat (setvar "osmode" oldsnap) (princ) Quote
Recommended Posts
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.