svorgodne Posted February 20, 2009 Share Posted February 20, 2009 I have several layouts in a template autocad file, which will be used several times due to size of the project and also because of the phase itself, so I need to divide the whole site A0 1:50 scale, decimal type. I have created already all the layouts, although the MVIEW is zoomed to the same point since I was only copying the layouts with subsequent numbers. Each tile from the grid I used for dividing the site is having also subsequent numbers, so afterwards on each layout I can zoom precisely to this entity by filtering contents to get thatt specific entity (number) and so on on each layout. Each number in the middle of each tile is unique and susequent to be able to zoom it in every layout in order to have the whole puzzle of the site. I found a little routine on the web that can filter the content of the text of the whole drawing: (ssget "_X" '((0 . "TEXT,MTEXT")(1 . "501"))) 501 would be one of these text content to be zoomed to a specific scale in ll the different layouts. I want to avoid to do it manually sincethis implies a lot of steps, so I think it could be possible to setup a variable with setq liusp command which could add one value everytime the routine is running so when I go to the next layout and run the routine the number would be 502. The problem I found is the number cannot be subsituted by the value of a variable defined by setq lisp command, therefore the whole routine is not useful. This is the routine I am using: (defun c:sss () (ssget "_X" '((0 . "TEXT,MTEXT") (1 . "501"))) (command "zoom" "o" "p" "" "zoom" "1000/50xp") ) I need to substitue the "501" for a variable defined previously by a setq. Is that possible? Plase help me, it is extremly urgent. Thanks Quote Link to comment Share on other sites More sharing options...
svorgodne Posted February 20, 2009 Author Share Posted February 20, 2009 sorry, I forgot to say it is AutoCAD 2006 the one I am using, Thanks again Quote Link to comment Share on other sites More sharing options...
CarlB Posted February 20, 2009 Share Posted February 20, 2009 Yes it's possible. You'll first need to convert the variable 'number' to 'text', as in; (setq Numtxt (rtos num 2 0));;if var is a real or int or (setq Numtxt (itoa num));;if var is an integer then (ssget "_X" (list '(0 . "TEXT,MTEXT") (cons 1 Numtxt))) Quote Link to comment Share on other sites More sharing options...
dchilders Posted January 17, 2011 Share Posted January 17, 2011 Hello, I'm having trouble getting this routine to work. Please bear with me I do not know how to write lisp code. I usually just find something that will work and load it. Any help with this would be greatly appreciated. When I run this one I get this error: ; error: bad argument type: fixnump: nil (defun c:sss () (setq Numtxt (itoa num));; (ssget "_X" (list '(0 . "TEXT,MTEXT") (cons 1 Numtxt))) (command "zoom" "o" "p" "" "zoom" "1000/200xp") ) When I run this one I get this error: ; error: bad argument type: numberp: nil (defun c:sss () (setq Numtxt (rtos num 2 0));; (ssget "_X" (list '(0 . "TEXT,MTEXT") (cons 1 Numtxt))) (command "zoom" "o" "p" "" "zoom" "1000/200xp") ) Basically what I have is a grid in model space and hundreds of layout tabs named according to each grid number (3548A1, 3548A2, 3548A3....). I would like to go to a layout, go inside thr viewport and run this routine. Hopefully the routine will promt me for a grid number (text) and find it and zoom it to a certain scale. Thanks in advance for any help with this. Quote Link to comment Share on other sites More sharing options...
lfe011969 Posted January 17, 2011 Share Posted January 17, 2011 I need to substitue the "501" for a variable defined previously by a setq. Is that possible?Thanks Does the value in quotes correspond to the layout number? Meaning on Layout1 would your ssget statement be this: (ssget "_X" '((0 . "TEXT,MTEXT")(1 . "1"))) then Layout2 would be "2" and so on? Quote Link to comment Share on other sites More sharing options...
dchilders Posted January 17, 2011 Share Posted January 17, 2011 To be honest I don't know. I'm really not sure how to write code. Is there anyway to have this routine promt me to input the grid number text I want it to zoom to? Thanks Quote Link to comment Share on other sites More sharing options...
lfe011969 Posted January 17, 2011 Share Posted January 17, 2011 To be honest I don't know. I'm really not sure how to write code. Is there anyway to have this routine promt me to input the grid number text I want it to zoom to? Thanks To ask the user for a string use this: (setq str (getstring "\nEnter text string to search for: ")) Others: real number = getreal integer = getint point = getpoint keyword = getkword Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 17, 2011 Share Posted January 17, 2011 Haven't read the whole thread, but maybe this will offer some insight: (defun c:FindText nil (sssetfirst nil (ssget "_X" (list (cons 0 "TEXT,MTEXT") (cons 1 (strcat "*" (getstring t "\nSpecify Text to Search for <All> : ") "*")) ) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 17, 2011 Share Posted January 17, 2011 The problem I found is the number cannot be subsituted by the value of a variable defined by setq lisp command, therefore the whole routine is not useful. To understand why, read this: http://www.cadtutor.net/forum/showpost.php?p=258390&postcount=20 Quote Link to comment Share on other sites More sharing options...
dchilders Posted January 17, 2011 Share Posted January 17, 2011 I tried running the code below, it promts me to enter a text string. For instance I entered 3647B3, and hit enter, it zooms to the scale I want but doesn't go to that text, it just zooms to a random spot? Thanks agian for all your help, this will be a life saver! (defun c:sss () (setq str (getstring "\nEnter text string to search for: ")) (command "zoom" "o" "p" "" "zoom" "1/100xp") ) Quote Link to comment Share on other sites More sharing options...
Lt Dan's legs Posted January 17, 2011 Share Posted January 17, 2011 quickly put together. To understand go to developer help and search for textbox (defun c:test (/ ent ang lst) (if (setq ent (car (entsel))) (progn (setq ang (cdr (assoc 50 (setq ent (entget ent)))) lst (mapcar '(lambda (x) (list (+ (car (cdr (assoc 10 ent))) (- (* (car x) (cos ang))(* (cadr x) (sin ang))) ) (+ (cadr (cdr (assoc 10 ent))) (+ (* (car x) (sin ang))(* (cadr x) (cos ang))) ) ) ) (textbox (list (assoc 1 ent))) ) ) (command "_.zoom" (nth 0 lst)(nth 1 lst)) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 17, 2011 Share Posted January 17, 2011 Try: (defun c:sss ( / ss ) (if (setq ss (ssget "_X" (list (cons 0 "TEXT,MTEXT") (cons 1 (strcat "*" (getstring t "\nSpecify Text to Search for <All> : ") "*")) ) ) ) (command "_.zoom" "_o" ss "" "_.zoom" "1/100xp") (princ "\n** Not Found **") ) (princ) ) Note that if more than more text object is found, all will be included in the zoom. If you wish to zoom to each object in turn, you will have to iterate through the selectionset. Quote Link to comment Share on other sites More sharing options...
dchilders Posted January 17, 2011 Share Posted January 17, 2011 I also tried this, and it work great for finding the text, but when I add the zoom cammand to it, it zooms to a random spot? (defun c:FindText nil (sssetfirst nil (ssget "_X" (list (cons 0 "TEXT,MTEXT") (cons 1 (strcat "*" (getstring t "\nSpecify Text to Search for : ") "*")) ) ) ) (princ) (command "zoom" "o" "p" "" "zoom" "1/100xp") ) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 17, 2011 Share Posted January 17, 2011 dchilders, Regarding code tags, read this also: http://www.cadtutor.net/forum/showthread.php?9184-Code-posting-guidelines Lee Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 17, 2011 Share Posted January 17, 2011 (edited) Some fun: ;; ZoomText © Lee Mac 2011 (defun c:ZoomText ( / ss ac l p1 p2 x ) (vl-load-com) (if (ssget "_X" (list (cons 0 "TEXT,MTEXT") (cons 1 (strcat "*" (vl-list->string (apply 'append (mapcar (function (lambda ( c ) (if (vl-position c '(35 64 46 42 63 126 91 123 44 96)) (list 96 c) (list c) ) ) ) (vl-string->list (getstring t "\nSpecify Text to Search for <All> : ") ) ) ) ) "*" ) ) ) ) (progn (vlax-for o (setq ss (vla-get-ActiveSelectionSet (vla-get-ActiveDocument (setq ac (vlax-get-acad-object)) ) ) ) (setq l (cons (cons o (progn (vla-getBoundingBox o 'p1 'p2) (list p1 p2) ) ) l ) ) ) (vla-delete ss) (while (setq x (car l)) (vla-ZoomWindow ac (cadr x) (caddr x)) (initget "Next Exit") (setq l (if (eq "Exit" (getkword "\nZoom to Next Object? [Next/Exit] <Next> : ")) nil (cdr l)) ) ) ) (princ "\n** None Found **") ) (princ) ) Edited January 17, 2011 by Lee Mac Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 17, 2011 Share Posted January 17, 2011 I also tried this, and it work great for finding the text, but when I add the zoom cammand to it, it zooms to a random spot? Note that if more than more text object is found, all will be included in the zoom. If you wish to zoom to each object in turn, you will have to iterate through the selectionset. ^^ Could be why Quote Link to comment Share on other sites More sharing options...
lfe011969 Posted January 17, 2011 Share Posted January 17, 2011 Nevermind Lee beat me to it, lol Quote Link to comment Share on other sites More sharing options...
dchilders Posted January 17, 2011 Share Posted January 17, 2011 Hey, sorry about not following the code posting guidelines, I'll make sure to do so in the future. Lee I ran that last routine, it works in model space, but when I go to a layout and open a viewport it does seem to work. Is it possible to do something like this from within a viewport or is this just a pipe dream. I basically tring to call up my grid number to a 1/100 scale. Thank you very much for your help Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 17, 2011 Share Posted January 17, 2011 Hey, sorry about not following the code posting guidelines, I'll make sure to do so in the future. No worries Lee I ran that last routine, it works in model space, but when I go to a layout and open a viewport it does seem to work. Is it possible to do something like this from within a viewport or is this just a pipe dream. I basically tring to call up my grid number to a 1/100 scale. Thank you very much for your help Sorry, I've now updated my code to remove the Layout filter, please try it again Quote Link to comment Share on other sites More sharing options...
dchilders Posted January 17, 2011 Share Posted January 17, 2011 Sweet, it works great! One last thing, with your Zoomtext routine, is there anywhere I can go in and change the scale becuase I have to do this periodicaly and the scales change? I looked thru it to see, but at this point most of these lisp codes look like hyroglifics to me. I'm very new to Autolisp. Quote Link to comment Share on other sites More sharing options...
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.