Author Topic: Dynamically Best Fit to a Scaled Viewport  (Read 207 times)

0 Members and 1 Guest are viewing this topic.

MSTG007

  • Water Moccasin
  • Posts: 2092
  • I can't remeber what I already asked! I need help!
Dynamically Best Fit to a Scaled Viewport
« on: November 20, 2017, 10:49:39 am »
If I have a page setup for 36x24 and the Viewport is the 36x24. Is there command that can do its best to assign a viewport scale to the object in model space (Xref or what not)?

I hope that makes some sense. Its one of those... its just a thought... lol.
Autodesk Infrastructure Design Suite 2017

Dommy2Hotty

  • Swamp Rat
  • Posts: 1110
Re: Dynamically Best Fit to a Scaled Viewport
« Reply #1 on: November 20, 2017, 05:18:17 pm »
I use these (2) that I cobbled together...not the prettiest, nor does it work everytime...I haven't had time to make them better, but they might lead you in the right direction:

Code: [Select]
;==============================================
;SET VIEWPORT BASED ON OBJECTS (1-1/2" = 1'-0")
;==============================================
(defun C:DomVIEWPORT_SetViewPortProfile ()
  (setq CurLayOut (getvar 'ctab))
  (command "pspace")
  (princ "\n*** SETVIEWPORT: PROFILE BY OBJECTS (1-1/2) ***")
  (setq ViewP (entsel "\nSelect VIEWPORT to modify: "))
  (setq ViewPEnt (entget (car ViewP)))
  (setq ViewPID (cdr (assoc 69 ViewPEnt)))
  (if Block
    ()
    (progn
      (setvar 'tilemode 1)
      (setq Block (ssget))
      (setvar 'ctab CurLayOut)
      );progn
    );if
  (command "mview" "lock" "off" ViewP "")
  (command "mspace")
  (setvar "cvport" ViewPID)
  (command "zoom" "object" Block "")
  (command "zoom" "scale" "1/8xp")
  (setq annoscale "1-1/2\" = 1'-0\"")
  (setvar "cannoscale" annoscale)
  (command "pspace")
  (command "mview" "lock" "ON" ViewP "")
  (setq Block nil)
  (princ)
  )

Code: [Select]
;=======================================================
;SET VIEWPORT BASED ON WINDOW SELECTION (1-1/2" = 1'-0")
;=======================================================
(defun C:DomVIEWPORT_SetViewPortProfileByWindow ()
  (setq CurLayOut (getvar 'ctab))
  (command "pspace")
  (princ "\n*** SETVIEWPORT: PROFILE BY WINDOW (1-1/2) ***")
  (setq ViewP (entsel "\nSelect VIEWPORT to modify: "))
  (setq ViewPEnt (entget (car ViewP)))
  (setq ViewPID (cdr (assoc 69 ViewPEnt)))
  (if Block
    ()
    (progn
      (setvar 'tilemode 1)
        (initget 1)
(setq pt1 (getpoint "\n\t***\tPick lower left corner\t*** \n : "))
(initget 1)
(setq pt2 (getcorner pt1 "\n\t***\tPick upper right corner\t*** \n : "))

      (setvar 'ctab CurLayOut)
      );progn
    );if
  (command "mview" "lock" "off" ViewP "")
  (command "mspace")
  (setvar "cvport" ViewPID)
  (command "zoom" "window" pt1 pt2)
  (command "zoom" "scale" "1/8xp")
  (setq annoscale "1-1/2\" = 1'-0\"")
  (setvar "cannoscale" annoscale)
  (command "pspace")
  (command "mview" "lock" "ON" ViewP "")
  (setq Block nil)
  (princ)
  )

MSTG007

  • Water Moccasin
  • Posts: 2092
  • I can't remeber what I already asked! I need help!
Re: Dynamically Best Fit to a Scaled Viewport
« Reply #2 on: November 21, 2017, 07:14:25 am »
Thanks a bunch for sharing. I will play around with this and hopefully get it to work! Thank you again!
Autodesk Infrastructure Design Suite 2017