Nikon Posted Monday at 05:22 PM Posted Monday at 05:22 PM I want to create a viewport in the space of a layout, the dimensions of which are equal to the specified polyline frame. But I get an error. Select a polyline: ; error: invalid argument type: consp <Object name: 7fffef13920> (defun c:crViewportFromPL ( / pts minPt maxPt width height) (setq pline (car (entsel "\nSelect a polyline: "))) (if (and pline (= (cdr (assoc 0 (entget pline))) "LWPOLYLINE")) (progn (setq pts (vl-remove-if 'listp (mapcar 'cdr (entget pline)))) (setq minPt (list (apply 'min (mapcar 'car pts)) (apply 'min (mapcar 'cadr pts)))) (setq maxPt (list (apply 'max (mapcar 'car pts)) (apply 'max (mapcar 'cadr pts)))) (setq width (- (car maxPt) (car minPt)))) (setq height (- (cadr maxPt) (cadr minPt)))) (command "_.-VPORTS" "_M" "1" "1" "0" "0" width height) ) ) (princ) ) Quote
GLAVCVS Posted Monday at 07:20 PM Posted Monday at 07:20 PM Hi Nikon With this code (vl-remove-if 'listp (mapcar 'cdr (entget pline)))) you can't get the list of points Quote
GLAVCVS Posted Monday at 07:24 PM Posted Monday at 07:24 PM Replace it with this (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget pline)))) 1 Quote
Nikon Posted Monday at 08:32 PM Author Posted Monday at 08:32 PM 1 hour ago, GLAVCVS said: Replace it with this (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget pline)))) Thanks, but the viewport is not being created in the sheet space, and the model space is divided into 4 viewports. ??? Quote
BIGAL Posted Monday at 10:13 PM Posted Monday at 10:13 PM Maybe use (setq pline (car (entsel "\nPick pline "))) (setq pts (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget pline))))) (command "Mview" (car pts)(caddr pts)) (command "Mspace") (command "Zoom" "E") 1 Quote
GLAVCVS Posted Monday at 10:13 PM Posted Monday at 10:13 PM (edited) (defun c:crViewportFromPL ( / pts minPt maxPt width height lst) (setq pline (car (entsel "\nSelect a polyline: "))) (if (and pline (= (cdr (assoc 0 (entget pline))) "LWPOLYLINE")) (progn (setq pts (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget pline)))) (setq minPt (list (apply 'min (mapcar 'car pts)) (apply 'min (mapcar 'cadr pts)))) (setq maxPt (list (apply 'max (mapcar 'car pts)) (apply 'max (mapcar 'cadr pts)))) (setq width (- (car maxPt) (car minPt))) ) (setq height (- (cadr maxPt) (cadr minPt))) ) (if (setq lst (layoutlist)) (progn (setvar 'CTAB (car lst)) (vl-cmdf "_zoom" "_w" minPt maxPt) ) ) ;;; (command "_.-VPORTS" "_M" "1" "1" "0" "0" width height) ) Edited Monday at 10:21 PM by GLAVCVS 1 Quote
GLAVCVS Posted Monday at 10:18 PM Posted Monday at 10:18 PM (edited) The best option is probably what BIGAL proposes '(command "zoom" "E")' This way you avoid having to get the list of points Edited Monday at 10:24 PM by GLAVCVS Quote
GLAVCVS Posted Tuesday at 05:18 AM Posted Tuesday at 05:18 AM 6 hours ago, GLAVCVS said: The best option is probably what BIGAL proposes '(command "zoom" "E")' This way you avoid having to get the list of points EXCEPT, if there are more objects in the drawing, of course. 1 Quote
Nikon Posted Tuesday at 06:35 AM Author Posted Tuesday at 06:35 AM (edited) 8 hours ago, GLAVCVS said: The best option is probably what BIGAL proposes '(command "zoom" "E")' This way you avoid having to get the list of points @GLAVCVS Yes, you're right. How to make the viewport display what is in the frame? Edited Tuesday at 06:48 AM by Nikon Quote
Nikon Posted Tuesday at 06:57 AM Author Posted Tuesday at 06:57 AM (edited) 8 hours ago, BIGAL said: Maybe use (setq pline (car (entsel "\nPick pline "))) (setq pts (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget pline))))) (command "Mview" (car pts)(caddr pts)) (command "Mspace") (command "Zoom" "E") How to make the viewport display what is in the frame? Everything that is in the model's space gets into the viewport. Edited Tuesday at 07:02 AM by Nikon Quote
BIGAL Posted Tuesday at 09:43 PM Posted Tuesday at 09:43 PM Ok once you make a viewport you need to zoom to a point inside Mspace, you can set the scale of the viewport also in this 2 step process. (command "zoom" "C" (getpoint '\PIck center point ") 100) (command "zoom" (strcat (rtos scale 2 2) "XP) When you zoom C it sets the viewport centre point, using scaleXP ie 4XP resets the viewport scale but keeps the centre point. If you have rectangs in Model space then yes can make layouts that match. You need to start with something like this. I have made rectangs that follow a pline. The software finds them and makes layouts. Another version allows user placement, both methods can be used then layouts made. Happy to discuss how its done, are you metric or imperial ? There is some behind the scenes set up. 1 Quote
Nikon Posted Wednesday at 06:17 AM Author Posted Wednesday at 06:17 AM (edited) 8 hours ago, BIGAL said: Happy to discuss how its done, are you metric or imperial ? ? There is some behind the scenes set up. @BIGAL Thanks. Yes, I'm very interested. I use the metric system. But first, I would like to understand with a simple example how to get a viewport based on the selected frame. For example, I have 3 frames in my model. I want to select one frame and get a viewport in the layout space that displays only the selected frame, not the entire drawing. And with the option to choose the scale. Edited Wednesday at 06:20 AM by Nikon Quote
BIGAL Posted Wednesday at 09:59 PM Posted Wednesday at 09:59 PM You do it in reverse to what you asked. you enter scale 1st. Then draw a rectang that matches the viewport in the layout scaled up or down to match scale. The other way is just pick a pt and use ZOOM C PT scale when in mspace use a dummy value for scale, then use zoom scXP the sc is simple for metres (setq sc (/ 1000 requiredscale) ) similar for mm a factor of 1000. The rotated rectangs answer will cost you a cup of coffee, as need to set up the rectang size to match say choices in paper size. 1 Quote
GLAVCVS Posted Wednesday at 10:33 PM Posted Wednesday at 10:33 PM 16 hours ago, Nikon said: @BIGAL Thanks. Yes, I'm very interested. I use the metric system. But first, I would like to understand with a simple example how to get a viewport based on the selected frame. For example, I have 3 frames in my model. I want to select one frame and get a viewport in the layout space that displays only the selected frame, not the entire drawing. And with the option to choose the scale. If I understand correctly, you want the 'LayOut' viewport to adapt proportionally to the selected rectangular polyline to display, by zooming, its content? 1 Quote
Nikon Posted yesterday at 06:21 AM Author Posted yesterday at 06:21 AM 7 hours ago, GLAVCVS said: If I understand correctly, you want the 'LayOut' viewport to adapt proportionally to the selected rectangular polyline to display, by zooming, its content? Yes, that's right. Quote
BIGAL Posted 23 hours ago Posted 23 hours ago I did give you an answer if you want rectangs start with the Viewport rectang the width and height in your layout title block. Then you draw the rectang to suit using the scale factor. Look at this front end. The match rotation part will cost you a coffee. (cond ((and (= sz "A0")(= orien "Landscape")) (setq ht 780.0 wid 1160.0 xpt 878.0 xwid 62.0 yht 32.0)) ((and (= sz "A1")(= orien "Landscape")) (setq Ht 541.0 wid 831.0 xpt 542.0 xwid 62.0 yht 32.0)) ((and (= sz "A1")(= orien "Portrait")) (setq Ht 774.0 wid 571.0 xpt 229.0 xwid 62.0 yht 32.0)) ((and (= sz "A2")(= orien "Landscape")) (setq ht 367.0 wid 584.0 xpt 295.5 xwid 62.0 yht 32.0)) ((and (= sz "A2")(= orien "Portrait")) (setq ht 554.0 wid 410.0 xpt 209.5 xwid 41.0 yht 23.0)) ((and (= sz "A3")(= orien "Landscape")) (setq ht 247.0 wid 400.0 xpt 200.0 xwid 41.0 yht 23.0)) ((and (= sz "A3")(= orien "Portrait")) ( close-drawrecs)) ((= sz "A4") (setq ht 180.0 wid 287.0)) ) Draw rectangs.mp4 1 Quote
Nikon Posted 23 hours ago Author Posted 23 hours ago (edited) 41 minutes ago, BIGAL said: I did give you an answer if you want rectangs start with the Viewport rectang the width and height in your layout title block. Then you draw the rectang to suit using the scale factor. Look at this front end. The match rotation part will cost you a coffee. I guess my English is really bad. I have A2, A3 frames in the model space... I want to select a frame and get a VP in the layout space of an A2 or A3 sized shit that displays the contents of one selected frame. No turns are needed yet... Edited 23 hours ago by Nikon Quote
GLAVCVS Posted 22 hours ago Posted 22 hours ago As Bigal says, unless you already have code for this, writing a tool like that is well worth 1 coffee. Or 2. I'll try to write something when I have enough time. Unless someone already has something to do this and is generous enough to share it 1 Quote
Nikon Posted 22 hours ago Author Posted 22 hours ago (edited) 3 hours ago, GLAVCVS said: As Bigal says, unless you already have code for this, writing a tool like that is well worth 1 coffee. Or 2. I'll try to write something when I have enough time. Unless someone already has something to do this and is generous enough to share it I already owe 50 cups of coffee to you and Mr. BIGAL for your help, where do you want it delivered? Edited 19 hours ago by Nikon Quote
GLAVCVS Posted 18 hours ago Posted 18 hours ago 4 hours ago, Nikon said: I guess my English is really bad. I have A2, A3 frames in the model space... I want to select a frame and get a VP in the layout space of an A2 or A3 sized shit that displays the contents of one selected frame. No turns are need An important issue is the paper size of the target layout. Because, regardless of the size of the rectangle in model space, it can be adapted to the layout in paper space (with the relevant scaling considerations, of course). Forcing the code to select one paper size or another based on the size of the rectangle in model space will make the job a bit more complicated. 1 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.