fabriciorby Posted June 14, 2013 Share Posted June 14, 2013 Hello, I've searched about this issue but I couldn't find anything useful to me. I'm trying to make something like this: I have a square inside my Model and a square ViewPort inside my Layout. I need to make the viewport to zoom to a point until the square inside my Model fits the ViewPort. I have no idea how to work with ViewPorts using lisp :/ I can upload a screenshot if it's too confusing Thank you (: Quote Link to comment Share on other sites More sharing options...
nestly Posted June 14, 2013 Share Posted June 14, 2013 Zoom > Object will zoom the "square" in model to the largest dimensions that will fit inside the viewport Doh... I overlooked that you're apparently looking for a lisp solution. Quote Link to comment Share on other sites More sharing options...
fabriciorby Posted June 14, 2013 Author Share Posted June 14, 2013 Zoom > Object will zoom the "square" in model to the largest dimensions that will fit inside the viewport How to select the viewport using lisp? Because what I really want to do is, for example, I have 10 squares in the drawing so a copy 10 layouts. For each Layout I need to get one of these squares and zoom. Quote Link to comment Share on other sites More sharing options...
fabriciorby Posted June 14, 2013 Author Share Posted June 14, 2013 And if I have 80 squares, for example, I would need to setvar 'ctab every time and it would take a long time. I was thinking about using the Model square points to get the zoom. I tried but I can't understand how VIEWPORT'S DXF works. I was thinking about (ssget "x" '((1 . "MVIEW")(410 . LAYOUTNAME))) and then changing their zoom properties. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 14, 2013 Share Posted June 14, 2013 Is this what you are after ? Don't select too much Closed LWpolylines . (defun c:Test (/ *error* o l i n ss in sn v ln) ;;--- Tharwat 15. June. 2013 ---;; (setq doc (vla-get-activedocument (setq o (vlax-get-acad-object)))) (defun *error* (x) (vla-put-LayoutCreateViewport (vla-get-display (vla-get-preferences o)) l ) (princ "\n*Cancel*") ) (setq l (vla-get-LayoutCreateViewport (vla-get-display (vla-get-preferences o)) ) i 1 n "Square-" ) (if (not l) (vla-put-LayoutCreateViewport (vla-get-display (vla-get-preferences o)) :vlax-true ) ) (if (setq ss (ssget '((0 . "LWPOLYLINE") (-4 . "<AND") (70 . 1) (90 . 4) (-4 . "AND>") ) ) ) (repeat (setq in (sslength ss)) (setq sn (ssname ss (setq in (1- in)))) (vla-getboundingbox (setq v (vlax-ename->vla-object sn)) 'j 'k ) (while (member (setq ln (strcat n (itoa i))) (layoutlist)) (setq ln (strcat n (itoa (setq i (1+ i))))) ) (vla-add (vla-get-layouts (vla-get-activedocument o)) ln) (setvar 'ctab ln) (vla-put-mspace doc :vlax-true) (vla-zoomWindow o j k ) (vla-put-mspace doc :vlax-false) ) ) (setvar 'ctab "Model") (princ) ) (vl-load-com) Quote Link to comment Share on other sites More sharing options...
BlackBox Posted June 14, 2013 Share Posted June 14, 2013 From within an activated viewport of the same scale: (command "._zoom" "window" "_end" pause "_end" pause) Quote Link to comment Share on other sites More sharing options...
fabriciorby Posted June 17, 2013 Author Share Posted June 17, 2013 Is this what you are after ? Don't select too much Closed LWpolylines . Wow, thank you Tharwat, your code can bring me a lot of ideas. (: (I'm so bad at VisualLisping) But is there a way of doing this without 'ctab? Only changing DXF values? You created an layout using VisuaLisp, is there a way to copy an layout with visual lisp? I mean, instead of using (command "layout" "copy")? You create a new viewport everytime, but, is there a way to select an existing one? If not, is there a way to change the viewport dimension while creating it? Quote Link to comment Share on other sites More sharing options...
fabriciorby Posted June 17, 2013 Author Share Posted June 17, 2013 From within an activated viewport of the same scale: (command "._zoom" "window" "_end" pause "_end" pause) Hm, this can be very helpful. I just need to get the viewport selected, because I'm going to have 2 viewports at the same layout ): Quote Link to comment Share on other sites More sharing options...
BlackBox Posted June 17, 2013 Share Posted June 17, 2013 Hm, this can be very helpful. I just need to get the viewport selected, because I'm going to have 2 viewports at the same layout ): I use it as a simple routine, so that I manually double click within the desired veiwport, and invoke as if a normal command: (defun c:ZW () (command "._zoom" "window" "_end" pause "_end" pause) (princ) ) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 17, 2013 Share Posted June 17, 2013 Wow, thank you Tharwat, your code can bring me a lot of ideas. You're welcome and happy to hear that . But is there a way of doing this without 'ctab? Only changing DXF values? What's wrong with the 'ctab ? actually we should use it in the code to port at the layout's deck to enter the viewport to zoom for a specific LWpolyline ( square ) . You created an layout using VisuaLisp, is there a way to copy an layout with visual lisp? I mean, instead of using (command "layout" "copy")? That way is not applicable in this case due to the sequence naming of layouts . Quote Link to comment Share on other sites More sharing options...
fabriciorby Posted June 17, 2013 Author Share Posted June 17, 2013 (edited) Yes, but I have written a code to make it applicabble (with help from the forum, sometime ago). Let me post it. [color=RED]([/color][color=BLUE]setq[/color] layouts [color=RED]([/color][color=BLUE]vla-get-layouts[/color] [color=RED]([/color][color=BLUE]vla-get-activedocument[/color] [color=RED]([/color][color=BLUE]vlax-get-acad-object[/color][color=RED]))))[/color] [color=#990099];; Temporarily rename layouts to reduce risk of duplication when renumbering[/color] [color=RED]([/color][color=BLUE]vlax-for[/color] layout layouts [color=RED]([/color][color=BLUE]if[/color] [color=RED]([/color][color=BLUE]/=[/color] [color=#a52a2a]"MODEL"[/color] [color=RED]([/color][color=BLUE]strcase[/color] [color=RED]([/color][color=BLUE]vla-get-name[/color] layout[color=RED])))[/color] [color=RED]([/color][color=BLUE]vla-put-name[/color] layout [color=RED]([/color][color=BLUE]vla-get-handle[/color] layout[color=RED]))[/color] [color=RED])[/color] [color=RED])[/color] [color=RED]([/color][color=BLUE]setq[/color] sfilter [color=RED]([/color][color=BLUE]list[/color][color=RED]([/color][color=BLUE]cons[/color] [color=#009900]8[/color] [color=#a52a2a]"NUM_FOLHA"[/color][color=RED])([/color][color=BLUE]cons[/color] [color=#009900]0[/color] [color=#a52a2a]"TEXT"[/color][color=RED])([/color][color=BLUE]cons[/color] [color=#009900]410[/color] [color=#a52a2a]"MODEL"[/color][color=RED])))[/color] [color=RED]([/color][color=BLUE]setq[/color] s [color=RED]([/color][color=BLUE]ssget[/color] [color=#a52a2a]"x"[/color] sfilter[color=RED]))[/color][color=#990099];; gets how many square numbering texts it has in the model[/color] [color=RED]([/color][color=BLUE]vlax-for[/color] layout layouts [color=RED]([/color][color=BLUE]if[/color] [color=RED]([/color][color=BLUE]not[/color] [color=RED]([/color][color=BLUE]=[/color] [color=#a52a2a]"MODEL"[/color] [color=RED]([/color][color=BLUE]strcase[/color] [color=RED]([/color][color=BLUE]vla-get-name[/color] layout[color=RED]))))[/color] [color=RED]([/color][color=BLUE]progn[/color] [color=RED]([/color][color=BLUE]vla-put-name[/color] layout [color=RED]([/color][color=BLUE]if[/color] [color=RED]([/color][color=BLUE]<[/color] [color=RED]([/color][color=BLUE]setq[/color] order [color=RED]([/color][color=BLUE]vla-get-taborder[/color] layout[color=RED]))[/color] [color=#009900]10[/color][color=RED])[/color] [color=RED]([/color][color=BLUE]setq[/color] layname[color=RED]([/color][color=BLUE]strcat[/color] [color=#a52a2a]"0"[/color] [color=RED]([/color][color=BLUE]itoa[/color] order[color=RED])))[/color] [color=RED]([/color][color=BLUE]setq[/color] layname[color=RED]([/color][color=BLUE]itoa[/color] order[color=RED]))[/color] [color=RED])[/color] [color=RED])[/color] [color=RED])[/color] [color=RED])[/color] [color=RED])[/color] And, your routine creates a new viewport everytime, but, is there a way to select an existing one? If not, is there a way to change the viewport dimension while creating it? Edited June 17, 2013 by fabriciorby editing code Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 17, 2013 Share Posted June 17, 2013 Yes, but I have written a code to make it applicabble (with help from the forum, sometime ago). Let me post it. You are renaming the layouts with their handles' strings and not copying them as you have asked before . And, your routine creates a new viewport everytime, but, is there a way to select an existing one? You can by the use of the 'ctab system variable and with global selection set for the same layout space (cons 410 (getvar 'ctab)) and then you should iterate through the selection set if it holds more than one viewport ans so on . Quote Link to comment Share on other sites More sharing options...
fabriciorby Posted June 17, 2013 Author Share Posted June 17, 2013 (edited) You are renaming the layouts with their handles' strings and not copying them as you have asked before . Yes, because I'm copying it manually. The first one is: 01, so the next ones are going to be 01 (2), 01 (3), 01 (4), ... and that's why I rename it, first with it's handles and then with taborder. edit: Oh, I'm sorry, I think I forgot to quote you and we got a misunderstanding here ): Edited June 17, 2013 by fabriciorby Quote Link to comment Share on other sites More sharing options...
fabriciorby Posted June 17, 2013 Author Share Posted June 17, 2013 I use it as a simple routine, so that I manually double click within the desired veiwport, and invoke as if a normal command: (defun c:ZW () (command "._zoom" "window" "_end" pause "_end" pause) (princ) ) I see, I was thinking about making it automatic, without double clicking. ): Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 17, 2013 Share Posted June 17, 2013 As far as I know there is not a function that does that same like the layout command call with the use of copy option as well , but if you are interested in copying the settings of one layout to another , you can use the function vla-copyfrom . Quote Link to comment Share on other sites More sharing options...
fabriciorby Posted June 17, 2013 Author Share Posted June 17, 2013 (edited) As far as I know there is not a function that does that same like the layout command call with the use of copy option as well , but if you are interested in copying the settings of one layout to another , you can use the function vla-copyfrom . Thank you, Tharwat. I'm going to try this function. (: I'm going to study your code, maybe I'll need to ressurect this topic soon hehehe Edited June 17, 2013 by fabriciorby Quote Link to comment Share on other sites More sharing options...
BlackBox Posted June 17, 2013 Share Posted June 17, 2013 I see, I was thinking about making it automatic, without double clicking. ): That would potentially require a persistent, per-Document, per-PViewport association storage mechanism that is dependent on an initial setup... Hardly automatic from the big picture, when we're talking about the simple task of picking two points. Just saying. Quote Link to comment Share on other sites More sharing options...
Guest kruuger Posted June 17, 2013 Share Posted June 17, 2013 copy thru layouts ? kruuger Copy2Layouts v1.01.lsp Quote Link to comment Share on other sites More sharing options...
fabriciorby Posted June 18, 2013 Author Share Posted June 18, 2013 That would potentially require a persistent, per-Document, per-PViewport association storage mechanism that is dependent on an initial setup... Hardly automatic from the big picture, when we're talking about the simple task of picking two points. Just saying. I don't know if I correctly understood you but, yes I'm going to use this lisp in templates already created (that are dwg and not dwt). All the squares are going to have a layer with its respective number, this number is gong to have its own layer too. What I'm doing is to get all squares from the layer and then getting their points to (ssget "wp") and get those numbers filtering by layer. Those numbers are going to be the layout name, so it's going to be "01", "02", "03"... I think it's going to work (: Quote Link to comment Share on other sites More sharing options...
fabriciorby Posted June 18, 2013 Author Share Posted June 18, 2013 copy thru layouts ? kruuger Actually, I'm not looking for this haha. Thank you kruuger, it's an interesting lisp by the way (: 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.