Jump to content

Recommended Posts

Posted
1 hour ago, GLAVCVS said:
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.

 ; *Creating viewports on layouts
	(if (= (getvar 'PSLTSCALE) 1) (setvar 'PSLTSCALE 0) )
    (setq Point1 (car (nth j Points))
	  Point2 (cadr (nth j Points))
	  PaperSpace (vla-get-paperspace ActiveDocument)
	  Point1x (car Point1) ; Getting coordinates from points
	  Point1y (cadr Point1)
	  Point2x (car Point2)
	  Point2y (cadr Point2)
	  ViewportHight (/ (abs (- Point1y Point2y)) Scale) ; Getting the height of the viewport
	  ViewportWidth (/ (abs (- Point1x Point2x)) Scale) ; Getting the viewport width
	  Viewport (vla-AddPViewport PaperSpace (vlax-3d-point (list (/ ViewportWidth 2) (/ ViewportHight 2))) ViewportWidth ViewportHight)) ;  viewports
    (vla-display Viewport :vlax-true)
    (vla-put-mspace ActiveDocument :vlax-true) ; Activating the model in the viewport
    (vla-zoomcenter Application (vlax-3d-point (list (/ (+ Point1x Point2x) 2) (/ (+ Point1y Point2y) 2))) 1.0) ; Centering the screen zoom
    (vla-put-mspace ActiveDocument :vlax-false) ; Deactivating the model space
    (vla-put-standardscale Viewport acVpCustomScale) ; Setting a custom viewport scale
    ;(vla-put-CustomScale Viewport 1.0) ; Setting the viewport scale
    (vla-put-CustomScale Viewport (/ (float 1) (float Scale))) ; Setting the viewport scale
    (vla-put-DisplayLocked Viewport "-1") ; Viewport Lock
    ;** Setting the print settings
    (vla-put-StyleSheet Layout "monochrome.ctb") ; Installing the Print style sheet
    (vla-put-PlotType Layout 5) ; Settings of the "layout" print area
    ;*** Setting the sheet formats
    (setq Square (* ViewportHight ViewportWidth)) ; Calculating the viewport area
    (cond ; Format selection depending on the viewport area
      ((and (> Square 59251) (< Square 65488)) (vla-put-ConfigName Layout "DWG To PDF.pc3") (vla-put-CanonicalMediaName Layout "ISO_full_bleed_A4_(297.00_x_210.00_MM)"))
      ((and (> Square 118503) (< Square 130977)) (vla-put-ConfigName Layout "DWG To PDF.pc3") (vla-put-CanonicalMediaName Layout "ISO_full_bleed_A3_(420.00_x_297.00_MM)"))
      ((and (> Square 237006) (< Square 261954)) (vla-put-ConfigName Layout "DWG To PDF.pc3") (vla-put-CanonicalMediaName Layout "ISO_full_bleed_A2_(594.00_x_420.00_MM)"))
      ((and (> Square 474012) (< Square 523908)) (vla-put-ConfigName Layout "DWG To PDF.pc3") (vla-put-CanonicalMediaName Layout "ISO_full_bleed_A1_(841.00_x_594.00_MM)"))
      ((and (> Square 948024) (< Square 1047816)) (vla-put-ConfigName Layout "DWG To PDF.pc3") (vla-put-CanonicalMediaName Layout "ISO_full_bleed_A0_(841.00_x_1189.00_MM)"))

 

Posted

What I mean is that any rectangle, whatever its size, can be fitted into an A4 Layout without any problem, even if it does not keep the proportions of the standard formats. Simply adjust the A4 Layout Viewport to the proportions of the rectangle taken as a reference in the model space. A zoom in the model space of this viewport will achieve the final effect.

But if you have to consider the size of the rectangle selected to use one Layout or another, everything is a little more complicated.

I hope I have explained myself better now.

  • Thanks 1
Posted (edited)
17 minutes ago, GLAVCVS said:

What I mean is that any rectangle, whatever its size, can be fitted into an A4 Layout without any problem, even if it does not keep the proportions of the standard formats.

I need to save scale and proportions.

I want to try to do this for at least one A2 frame, for example...

Edited by Nikon
Posted

Ok PM me I will talk via email. Yes you select scale and title block size, the title block is read from say a dwg containing all your layouts pre set up. Or can be made to match each title block that is inside the current dwg. As per code I posted all the size details are hard coded. You make say one or more rectang then just run step 2 and make the layouts. If you want different size then just run step one again.  

image.png.daa236c020d803633b1a3434bae4369b.png

 

I need to see your title blocks in a dwg to work out settings.

 

The other thing I did was a plottopdf.lsp that auto reads the title block name in a layout so matches correct plot settings again hard coded.

  • Thanks 1
Posted
8 hours ago, BIGAL said:

 

I need to see your title blocks in a dwg to work out settings.

 

The other thing I did was a plottopdf.lsp that auto reads the title block name in a layout so matches correct plot settings again hard coded.

Thanks, I don't need a very complicated program.
I just have polyline frames A2 in the model space (there are no title blocks).
I want to try to do this for at least one A2 frame, for example...

Posted (edited)

Hey @Nikon,

 

If I can give you some advice. I had the same situation about 2-3 years ago, and I've been thinking about how to do automatization in creating layouts. And, I figure it out the best way (for my purpose) is to make differents "dwg" with appropriate size of viewports with accompanying "dwt" files (where are you going to have a "block" section with the name of company, number of project, name of the project, etc.).

 

The first one is to make a different sizes of desired viewports. This one from picture 1 is for the 297x420 cm paper size.

 

image.png.8d52999813c531c869187d7e17c20f54.png

 

The second one is to make a "dwt" files where are you going to put your viewport inside the layout. The picture 2 show how it looks layout for the paper size 297x420 cm.

 

image.png.6b776129a62e7c47513a1a7b2cd83f55.png

 

The third one is coding (this is the first time when I created something using autolisp, the first program). It will look like this (this is the part from the code):

 

(while (< i len)
    (setq base nil)
    (setq xy nil)
    (setq obj (ssname ss i))
    (setq data1 (entget (ssname ss i)))
    (setq blockname (cdr (assoc 2 data1)))
    (cond
      ((= blockname L1)
       (setq data2 (entget (entnext (cdr (assoc -1 data1)))))
       (setq data3 (entget (entnext (cdr (assoc -1 data2)))))
       (setq data4 (entget (entnext(cdr (assoc -1 data3)))))
       (setq base (cdr (assoc 11 data3)))
       (setq xy (cdr (assoc 1 data3)))
       (setq no (1+ i))
       (setq data4 (subst (cons 1 (itoa no)) (assoc 1 data4) data4))
       (entmod data4)
       (setq nno (strcat v1 "." v2 "." (itoa no)))
       (setq path (findfile ".\\Situacioni plan saobracajne signalizacije_297x420.dwt"))
       (command "layout" "t" path "1")
       (command "layout" "s" "1")
       (command "layout" "r" "" nno)
       (command "mspace" "ucs" "ob" obj "plan" "c" "zoom" "w" base xy "pspace")
       )
       ...................

 

I hope I gave you some idea, it is simillar as @BIGAL proposal.

 

Best regards.

Edited by Saxlle
  • Like 1
  • Thanks 1
Posted (edited)
16 hours ago, Nikon said:

I need to save scale and proportions.

I want to try to do this for at least one A2 frame, for example...

 

What measurements will the rectangles have in the model space and/or what should the scale be?

Edited by GLAVCVS
Posted
1 hour ago, GLAVCVS said:

What measurements will the rectangles have in the model space and/or what should the scale be?

The dimensions of the frame in the model space are 594x420mm, scale 1:1.
Only one selected frame should be included in the viewport, not the entire drawing.

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