Author Topic: Recover a zoom in a floating viewport after a change of coordinate system  (Read 1533 times)

0 Members and 1 Guest are viewing this topic.

fabcad

  • Newt
  • Posts: 43
Hello to all,
In our organization, we have about a thousand files dwg (some external references) we need to move from one coordinate system to another.
But with this change of coordinates, we lose the zoom window for each presentation and therefore it seemed wise to create a way to re-zoom into each window presentations.
First function :
- In each layout, creates a rectangle / lwpolyligne (for viewport rectangular) or polyline (for polygon viewport).
- Put the rectangle or the polyline in a layer "areas-impressions-(layout name)".
- Associate in Xdata  or Ldatas the name of the layout, the file name, the angle of scu if the scu is different from general.
- Place the rectangle or the polygon from space layout to model space as the "_chspace" or by other means.

Second function :
- Select all the polylines with "areas-impressions-*" layers.
- Collect informations : name of the layout.
- Go to the presentation attached to zoom and orient with the polyline.

Thanks for help

A french "Breton"
« Last Edit: January 25, 2012, 11:18:22 AM by fabcad »

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: zoom with polylines
« Reply #1 on: January 23, 2012, 06:31:28 AM »
A "partial" startpoint for you might be this: http://forums.augi.com/showthread.php?t=94760

Note (as I've stated in that thread): It's easier to implement such from a block instead of a polyline, since it's not uncommon for a polyline to have a startpoint at any one of its vectors - thus not an easy task to figure out where the bottom-left and top-right is.

You could simply place a temporary block containing a 1x1 rectangle, then adjust its X & Y scale factors by the width & height. That way it's not too difficult to figure out later what rotation about which base point to use when re-setting the viewports.

For that matter a viewport saves its centre point, rotation and view factor - which is a lot more analogous to a block with its insertion point in its centre. Just a suggestion.  :laugh:
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

fabcad

  • Newt
  • Posts: 43
Thanks irneb,

This is a great idea !

This is my first code to help me go further please.
PS : The names of the three attributes of the block "viewport" are LAYER_NAME, LAYOUT_NAME and SCU.
Code: [Select]
(defun C:insert_bloc_viewport
(/
calque calque_vl
centre centre_vl
hauteur hauteur_vl
longueur longueur_vl
objet_acad_viewport
objet_vl_viewport
ss_viewport
)
(vl-load-com)
(setq block "viewport")

(foreach layout (layoutlist)
(command "presentation" "Etablir" layout)
(command "espacep")
(command "resol" "in")
;select viewport boundary
(setq ss_viewport (ssget (list '(0 . "VIEWPORT"))))
(setq objet_acad_viewport (entget (ssname ss_viewport 0)))
(setq objet_vl_viewport (vlax-ename->vla-object (ssname ss_viewport 0)))
;Get Viewport height with
(setq hauteur (cdr (assoc 41 objet_acad_viewport)))
;Get Viewport width with
(setq longueur (cdr (assoc 40 objet_acad_viewport)))
;Get Viewport Number
(setq centre (cdr (assoc 10 objet_acad_viewport)))
;Get Viewport Calque
(setq calque (cdr (assoc 8 objet_acad_viewport)))

;Get Viewport height with
(setq hauteur_vl (vla-get-height objet_vl_viewport))
;Get Viewport width with
(setq longueur_vl (vla-get-width objet_vl_viewport))

;Get Viewport Centre
;(setq centre_vl (vla-get-center objet_vl_viewport))
;(setq pointlist (vlax-3d-point centre_vl)

;Get Viewport Calque
(setq calque_vl (vla-get-layer objet_vl_viewport))

(command "_.insert" block centre longueur hauteur "0")
(command "_chspace" (entlast) "")
(setq objet_vl_bloc_viewport (vlax-ename->vla-object (entlast)))
(setq calque_bloc (strcat "print_zone-" (getvar "CTAB")))

(if (not (tblobjname "LAYER" calque_bloc))
(vla-add (vla-get-Layers (vla-get-ActiveDocument (vlax-get-acad-object))) calque_bloc)
)

(vla-put-layer objet_vl_bloc_viewport calque_bloc)
(command "espacep")
);fin foreach
(princ)
);fin defun
« Last Edit: January 25, 2012, 11:18:34 AM by fabcad »