Author Topic: Create Viewports from rectangles in Model space  (Read 2470 times)

0 Members and 1 Guest are viewing this topic.

clotho

  • Guest
Create Viewports from rectangles in Model space
« on: July 01, 2016, 03:50:11 AM »
Hi every body,

Please I need a lisp witch can create multiple viewports from rectangles in model space.
There are some lisps in autodesk forum and in this forum but they doesn't work.

Thank you in advance.

kruuger

  • Swamp Rat
  • Posts: 637
Re: Create Viewports from rectangles in Model space
« Reply #1 on: July 01, 2016, 07:26:17 AM »
Hi every body,

Please I need a lisp witch can create multiple viewports from rectangles in model space.
There are some lisps in autodesk forum and in this forum but they doesn't work.

Thank you in advance.
so far best tool to create/sync model bordes with paper viewports.
http://u-cad.eu/apps/viewportmaster/
k.

clotho

  • Guest
Re: Create Viewports from rectangles in Model space
« Reply #2 on: July 01, 2016, 08:30:04 AM »
Thanks you for your help but this is not what i'm looking for.

I need to create layouts from model space. (see attachement image).

I have found a code. It doesn't work perfectly but I can adjust it. The problem is that it can not rotate views. if all rectangles are aligned horizontally there no problem, else it doesn't word :(

Code: [Select]
defun C:CEPX (/ ACDOC B C FEN I LAYS N-P NOM-P ONG-BASE ONG_DEST SEL XMIN YMAX A-P HAUT LARG P1 P2 NOM ECH LAY LOCK UNIT)

  (vl-load-com)

  ; 4 Millimètres 5 Centimètres 6 Mètres

  (setq UNIT (cdr (assoc (getvar "INSUNITS") '((4 . 1) (5 . 10) (6 . 1000)))))

 

  (while (not SEL)

    (setq SEL (car (entsel "\n Choix du cadre (Bloc) :")))

    (setq BLK (cdr (assoc 2 (entget SEL))))

    (if SEL

      (if (not (equal (vla-get-objectname (setq B (vlax-ename->vla-object SEL))) "AcDbBlockReference"))

        (setq SEL NIL)))

    )

 

   [surligneur] (setq SEL

        (ssget "X" (list (cons 2 BLK)))

        ACDOC (vla-get-activedocument (vlax-get-acad-object))

        LAYS  (layoutlist)

        )

  (setq BLK NIL)

[/surligneur]

  (if (> (length LAYS) 1)

    (progn (princ "\n Copie configuration traceur d'onglet Existant. \n Plusieurs Présentations détectées.")

      (while    (not ONG-BASE)

        (princ "\n")

        (repeat (setq I (length LAYS))

          (princ (strcat (nth (- (length LAYS) I) LAYS) " * "))

          (setq I (1- I))

          )

        (setq ONG-BASE (getstring t "\n Présentation d'où la configuration du traceur sera récupérée :"))

        (if (not (member ONG-BASE LAYS))

          (setq ONG-BASE NIL)

          )

        )

      )

    (setq ONG-BASE (car LAYS))

    )

  (setq A-P (vla-item (vla-get-layouts ACDOC) ONG-BASE))

  (vla-getcustomscale A-P 'N 'M)

  (vla-put-activelayout ACDOC A-P)

  (vlax-for E (vla-get-paperspace ACDOC)

    (if (equal (vla-get-objectname E) "AcDbViewport")

      (setq LAY  (vla-get-layer E)

            LOCK (vla-get-displaylocked E)

            )

      )

    )

  (setq I 0)

  (repeat       (sslength SEL)

    (if (vlax-property-available-p (vlax-ename->vla-object (ssname SEL I)) 'EFFECTIVENAME)

      (setq NOM vla-get-effectivename)

      (setq NOM vla-get-name)

      )

    (if (equal (NOM (setq C (vlax-ename->vla-object (ssname SEL I)))) (NOM B))

      (progn

        (vla-getboundingbox C 'XMIN 'YMAX)

        (setq LSTIMA      (GETATT C)

              NBLSTIMA (length LSTIMA)

              IMA1        (cdr (nth 27 LSTIMA))                 ;;; Numéro de folio du bloc

;;;           IMA2        (cdr (nth 28 LSTIMA))                 ;;; Nom de document ERAS

              )

        (setq ONG_DEST IMA1)

;;;     (if (/= IMA2 "")                                        ;;; Concatenation de numéro de folio et du Nom du document ERAS

;;;       (setq ONG_DEST (strcat ONG_DEST "_" IMA2))

;;;       )

        (setq N-P (vla-add (vla-get-layouts ACDOC) ONG_DEST))

        (setq ECH (vla-get-yscalefactor C))

        (vla-copyfrom N-P A-P)

        (vla-put-activelayout ACDOC N-P)

        (setq FEN

               (vla-addpviewport (vla-get-paperspace ACDOC)

                 (vlax-3d-point '(0 0 0))

                 (setq Larg (* Unit (/ (- (car (vlax-safearray->list ymax)) (car (vlax-safearray->list xmin))) ech)))

                 (setq Haut (* Unit (/ (- (cadr (vlax-safearray->list ymax)) (cadr (vlax-safearray->list xmin))) ech)))))

        (vla-put-layer FEN LAY)

        (vla-put-displaylocked FEN LOCK)

        (vla-zoomextents (vlax-get-acad-object))

        (vla-display FEN :vlax-true)

        (vla-put-mspace ACDOC :vlax-true)

        (vla-put-activepviewport ACDOC FEN)

        (vla-zoomwindow (vlax-get-acad-object) XMIN YMAX)

        (vla-put-mspace ACDOC :vlax-false)

        (if (> (- (car (vlax-safearray->list YMAX)) (car (vlax-safearray->list XMIN)))

               (- (cadr (vlax-safearray->list YMAX)) (cadr (vlax-safearray->list XMIN)))

               )

          (vla-put-plotrotation (vla-get-activelayout ACDOC) ac90degrees)

          (vla-put-plotrotation (vla-get-activelayout ACDOC) ac0degrees)

          )

        (setq P1 (vlax-make-safearray vlax-vbdouble (cons 0 1))

              P2 (vlax-make-safearray vlax-vbdouble (cons 0 1))

              )

        (vlax-make-variant

          (vlax-safearray-fill P1 (list (- (/ LARG 2)) (- (/ HAUT 2)))))

        (vlax-make-variant

          (vlax-safearray-fill P2 (list (/ LARG 2) (/ HAUT 2))))

;;;GR   (vla-put-plottype (vla-get-activelayout ACDOC) acwindow)

        (vla-setwindowtoplot (vla-get-activelayout ACDOC) P1 P2)

        (setq I (1+ I))

        )

      )

    )

  (setvar "TILEMODE" 1)

  (princ)

  )

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Create Viewports from rectangles in Model space
« Reply #3 on: July 01, 2016, 10:51:00 AM »
I thought there was some code to do that but no time to look this morning.
https://goo.gl/V1BQtR
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.