How to create automatic layouts

How to create automatic layouts

Anonymous
Not applicable
43,606 Views
116 Replies
Message 1 of 117

How to create automatic layouts

Anonymous
Not applicable

Hi Everyone,

 

Please help me to create automatic layouts for the attached drawing

 

Also request you to please provide me the LISP/FAS file.

 

The attache dwg is simple drawing. But i have 200 grids in some cases.

 

Please help on this.

 

Thank you in advance. 

0 Likes
Accepted solutions (1)
43,607 Views
116 Replies
Replies (116)
Message 41 of 117

Anonymous
Not applicable

Hi maratovich, internet problems i guess.

 

well, i said it doesn't work well with rotated rectangles. in paper space i see the rotated ones twisted.

 

any suggestion?

 

0 Likes
Message 42 of 117

maratovich
Advisor
Advisor

This is a universal solution.

AutoViewport - Automatic creation layouts and viewport 
Main functions: 
- automatic creation layouts; 
- creation of rectangular viewports on layouts; 
- creation of rotated viewports on layouts; 
- selection of required layout name; 
- select print settings for layout.

 

 

Деморолик Screencast появится здесь после нажатия кнопки "Опубликовать".

 

 2.png

 
---------------------------------------------------------------------
Software development
Automatic creation layouts and viewport. Batch printing drawings from model.
www.kdmsoft.net
0 Likes
Message 43 of 117

maratovich
Advisor
Advisor

 

 

 

https://autode.sk/2N4pHNf

Screencast bad work

---------------------------------------------------------------------
Software development
Automatic creation layouts and viewport. Batch printing drawings from model.
www.kdmsoft.net
0 Likes
Message 44 of 117

Anonymous
Not applicable

Hello, 

I'm struggling to make this lisps work for me too, but as I don't kno how to program in lisps I can't figure out what's the matter. What is the command for this lisp?  or should it do the job automatically as soon as I load it from 'Load Application' in Autocad? 

thank you very much ,

Gesana

0 Likes
Message 45 of 117

Anonymous
Not applicable

Hello,

 

I am looking to use a very similar program to create automated layouts with viewports.  Would you be able to take a look at my test dwg file and make a few adjustments for this to work with the title block I have created?  any help is greatly appreciated!

 

Thanks,

 

Will

0 Likes
Message 46 of 117

Anonymous
Not applicable

hello sir can you please make video on how to apply this code. i really appreciate one. thank you in advance.

0 Likes
Message 47 of 117

Anonymous
Not applicable

Can someone modify this for just only one viewport? Just for the main viewport

(defun GridsToLayouts ( UseUndoMarks / GridLayer GridAttribute SourceLayout TitleBlockHeight KeyZoomFactor
                                       TitleBlockName TitleBlockSheetNumberAttribute TitleBlockTotalSheetsAttribute
                                       vl-GetAttributeValue
                                       ss i enam edata grids grid id previd ssvp1 vp1 vpno1 ssvp2 vp2 vbno2 ptmin ptmax)
  (vl-load-com)

  ;;;*SOME SETTINGS THAT CAN BE CUSTOMIZED
  (setq GridLayer                        "GRID")
  (setq GridAttribute                    "MAPSHTNUM")
  (setq SourceLayout                     "001")
  (setq TitleBlockHeight                 86)
  (setq KeyZoomFactor                    0.5)
  ;(setq TitleBlockName                   "XXX_2")
  ;(setq TitleBlockSheetNumberAttribute   "SHEET_NO")
  ;(setq TitleBlockTotalSheetsAttribute   "NO_OF_SHEETS")

  (defun vl-GetAttributeValue ( blk tag )
    (setq tag (strcase tag))
    (vl-some '(lambda ( att ) (if (= tag (strcase (vla-get-tagstring att))) (vla-get-textstring att)))
        (vlax-invoke blk 'getattributes)
    )
  )
 
  (cond
   ((not (setq ss (ssget "x" (list (cons 0 "INSERT") (cons 8 GridLayer)))))
    (princ (strcat "\nNo grid blocks on layer '" GridLayer "' found."))
   )
   ((not (member SourceLayout (layoutlist)))
    (princ (strcat "\nSource layout '" SourceLayout "' not found."))
   )
   ((> (length (layoutlist)) 1)
    (princ (strcat "\nOnly layouts 'Model' and '" SourceLayout "' should exist."))
   )
   (T
    (setq i 0)
    (while (< i (sslength ss))
	  (setq edata (entget (setq enam (ssname ss i))))
      (if (and
            (= (cdr (assoc 0 edata)) "INSERT")
            (setq attval (vl-GetAttributeValue (vlax-ename->vla-object (cdr (assoc -1 edata))) GridAttribute))
          )
        (setq grids (cons (cons attval enam) grids))
      )
      (setq i (1+ i))
    )
    (setq grids (vl-sort grids (function (lambda (e1 e2) (< (car e1) (car e2))))))

    
    (if UseUndoMarks (vla-StartUndoMark (vla-get-ActiveDocument (vlax-get-acad-object))))
    (if grids
      (princ "\nCreating layouts...")
      (princ "\nNo grids found...")
    )
    (foreach grid grids
      (if grids
        (progn
          (setq id (car grid) enam (cdr grid))
          (princ (strcat "\nCreating layout '" id "'... "))
          (if (not (member id (layoutlist)))
            (command "._layout" "c" previd id)
          )
          (command "._layout" "s" id "._pspace")
          (if (and
                (setq ssvp1 (ssget "x" (list (cons 0 "VIEWPORT") (cons -4 "*,>,*") (list 10 0 TitleBlockHeight 0))))
                (setq ssvp2 (ssget "x" (list (cons 0 "VIEWPORT") (cons -4 "*,<,*") (list 10 0 TitleBlockHeight 0))))
              )
            (progn
              (vla-getboundingbox (vlax-ename->vla-object enam) 'ptmin 'ptmax)
              (setq vpno1 (cdr (assoc 69 (entget (setq vp1 (ssname ssvp1 0))))))
              (setq vpno2 (cdr (assoc 69 (entget (setq vp2 (ssname ssvp2 0))))))
              (command "._mspace")
              (setvar "CVPORT" vpno1)
              (vla-zoomwindow (vlax-get-acad-object) ptmin ptmax)
              (setvar "CVPORT" vpno2)
              (vla-zoomwindow (vlax-get-acad-object) ptmin ptmax)
              (vla-zoomscaled (vlax-get-acad-object) KeyZoomFactor acZoomScaledRelative)
              (command "._pspace")
              (vla-zoomextents (vlax-get-acad-object))
            )
            (princ (strcat "\nUnable to find the two vieports needed for layout " id))
          )
          (setq previd id)
          (if (= (length (layoutlist)) 255)
            (progn
              (princ "\nMaximum number of layouts met.")
              (setq grids nil)
            )
          )
          (vla-eval (vlax-get-acad-object) "DoEvents")
        )       
      )
    )
    (princ "\... GridsToLayouts finished.")
    (if UseUndoMarks (vla-EndUndoMark (vla-get-ActiveDocument (vlax-get-acad-object))))
   )
  )
)

(defun C:GridsToLayouts nil (GridsToLayouts T) (princ))
0 Likes
Message 48 of 117

vipuldhruv9215
Participant
Participant

Hello Similar Requirement for my work.

 

pl help me preparing Automatic Multiple Layout Creation.

 

Here with attache test file for your reference.

 

Thanks in advance.

  

0 Likes
Message 49 of 117

maratovich
Advisor
Advisor

@vipuldhruv9215 wrote:

Hello Similar Requirement for my work.

 

pl help me preparing Automatic Multiple Layout Creation. 


 

 

---------------------------------------------------------------------
Software development
Automatic creation layouts and viewport. Batch printing drawings from model.
www.kdmsoft.net
Message 50 of 117

vipuldhruv9215
Participant
Participant

Thanks But Pl prepared Auto lips file for this?

 

 

Message 51 of 117

vipuldhruv9215
Participant
Participant

Not Properly work pl prepare any autolip program for this

0 Likes
Message 52 of 117

diagodose2009
Collaborator
Collaborator

You check Js_aro10 Routine inside lisp.

 

 

	 ssvp2 nil) (if (js_aro10 "C049member" (list  id (js_aro10 "C048layoutlist" (list )))) (setq nop (js_aro10 "C050dfn_cmd_canceld" (list ))
 nop (command "._layout" "s" id "._pspace") ssvp1 (js_aro10 "C053ssget" (list  "x" (list (js_aro10 "C051cons" (list  0 "VIEWPORT")) (js_aro10 "C052cons" (list  (- 4) "*,>,*")) (list 10 0 TitleBlockHeight 0)))))) (setq ssvp2 (if (/= ssvp1 nil) (js_aro10 "C056ssget" (list  "x" (list (js_aro10 "C054cons" (list  0 "VIEWPORT")) (js_aro10 "C055cons" (list  (- 4) "*,<,*")) (list 10 0 TitleBlockHeight 0)))) nil)) (if (and  ssvp2 ssvp1) (setq nop (js_aro10 "C058vla-getboundingbox" (list  (js_aro10 "C057vlax-ename->vla-object" (list  enam)) 'ptmin 'ptmax)) vp1 (js_aro10 "C059ssname" (list  ssvp1 0))vp2 (js_aro10 "C060ssname" (list  ssvp2 0)))) (if (and  vp1 vp2) (setq vpno1 (cdr (js_aro10 "C062assoc" (list  69 (js_aro10 "C061entget" (list  vp1))))) vpno2 (cdr (js_aro10 "C064assoc" (list  69 (js_aro10 "C063entget" (list  vp2))))))) (if (and  vpno1 vpno2 ptmin ptmax) (progn (js_aro10 "C065dfn_cmd_canceld" (list )) (command "._mspace") (js_aro10 "C066setvar" (list  "CVPORT" vpno1)) (js_aro10 "C068vla-zoomwindow" (list  (js_aro10 "C067vlax-get-acad-object" (list )) ptmin ptmax)) (js_aro10 "C069setvar" (list  "CVPORT" vpno2)) js_aro10 "C071vla-zoomwindow" (list  (js_aro10 "C070vlax-get-acad-object" (list )) ptmin ptmax)) (js_aro10 "C073vla-zoomscaled" (list  (js_aro10 "C072vlax-get-acad-object" (list )) KeyZoomFactor acZoomScaledRelative)) (js_aro10 "C074dfn_cmd_canceld" (list )) (command "._pspace") (js_aro10 "C076vla-zoomextents" (list  (js_aro10 "C075vlax-get-acad-object" (list ))))) (js_aro10 "C077str_princ" (list (list "\nerror**Unable to find the two vieports needed for layout " id)))) (setq previd id) (if (>= (js_aro10 "C079length" (list  (js_aro10 "C078layoutlist" (list )))) 254) (setq grids (js_aro10 "C080alert" (list  "\nerror**eMaxLayouts_i408, Maximum number of layouts met.")) grids nil))) (js_aro10 "C082vla-eval" (list  (js_aro10 "C081vlax-get-acad-object" (list )) "DoEvents"))))) (js_aro10 "C083alert" (list  "\... GridsToLayouts finished.")) (if (and UseUndoMarks (>  layoutMngr 0)) (js_aro10 "C086vla-endundomark" (list  (js_aro10 "C085vla-get-activedocument" (list  (js_aro10 "C084vlax-get-acad-object" (list ))))))) 

 

Q:What is js_aro10? 

A: Js_aro10 save mypid-address for all functions. When your "pp_sudhakar99919_jsaro10.vlx" crash, or bug-error, you type (princ setmypid) [enter] at line-command. You search (eg: "C083" )inside the file pp_sudhakar99919_jsaro10.lsp and you, will found fast-speed the Error-Location.

Q: How to Testing ?

A:You open attrib.dwg and appload.

0 Likes
Message 53 of 117

maratovich
Advisor
Advisor

Have you watched the video? There is no Lisp. Lisp is uncomfortable for me.

---------------------------------------------------------------------
Software development
Automatic creation layouts and viewport. Batch printing drawings from model.
www.kdmsoft.net
0 Likes
Message 54 of 117

diagodose2009
Collaborator
Collaborator

You execute "pp_sudhakar99919_jsaro10.lsp" . You see winlogon.gif.

, work fine, you test "pp_sudhakar99919_default.lsp" with attrib.dwg

0 Likes
Message 55 of 117

maratovich
Advisor
Advisor

 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
---------------------------------------------------------------------
Software development
Automatic creation layouts and viewport. Batch printing drawings from model.
www.kdmsoft.net
0 Likes
Message 56 of 117

maratovich
Advisor
Advisor

.

 

---------------------------------------------------------------------
Software development
Automatic creation layouts and viewport. Batch printing drawings from model.
www.kdmsoft.net
Message 57 of 117

vipuldhruv9215
Participant
Participant

Not work pl check 

0 Likes
Message 58 of 117

devitg
Advisor
Advisor

@vipuldhruv9215 , please upload your sample dwg. To test it. 

0 Likes
Message 59 of 117

vipuldhruv9215
Participant
Participant

pl attached test file

0 Likes
Message 60 of 117

allanthebruce
Advocate
Advocate

Looks fantastic, I have tried this with a metric system template in Civil3d and it does not work, very much appreciated if you can have a look at my sample attached, maybe something I am missing or a units thing?

Thanks

Allan

0 Likes