Code Red > AutoLISP (Vanilla / Visual)

viewport annotation scale from a viewport object?

(1/1)

mkweaver:
Given a pviewport object, how can I find out if/what annotation scale has been set?

A viewport with it's annotative property turned on, and 1/4" = 1'-0" added and active has the following entity list:


--- Code: ---((-1 . <Entity name: 7deee828>)
  (0 . "VIEWPORT")
  (5 . "2645")
  (102 . "{ACAD_XDICTIONARY")
  (360 . <Entity name: 7deee830>)
  (102 . "}")
  (330 . <Entity name: 7dee2d40>)
  (100 . "AcDbEntity")
  (67 . 1)
  (410 . "Layout1")
  (8 . "MVIEW")
  (100 . "AcDbViewport")
  (10 29.6203 20.4803 0.0)
  (40 . 11.4448)
  (41 . 14.0507)
  (68 . 2)
  (69 . 2)
  (12 4872.81 -8802.63 0.0)
  (13 0.0 0.0 0.0)
  (14 0.5 0.5 0.0)
  (15 0.5 0.5 0.0)
  (16 0.0 0.0 1.0)
  (17 0.0 0.0 0.0)
  (42 . 50.0)
  (43 . 0.0)
  (44 . 0.0)
  (45 . 674.431)
  (50 . 0.0)
  (51 . 0.0)
  (72 . 1500)
  (90 . 835616)
  (281 . 0)
  (71 . 1)
  (74 . 0)
  (110 0.0 0.0 0.0)
  (111 1.0 0.0 0.0)
  (112 0.0 1.0 0.0)
  (79 . 0)
  (146 . 0.0)
  (170 . 0)
  (61 . 5)
  (348 . <Entity name: 7deee4a0>)
  (292 . 1)
  (282 . 1)
  (141 . 0.0)
  (142 . 0.0)
  (63 . 250)
  (421 . 3355443)
  (-3 ("ACAD" (1000 . "MVIEW")
      (1002 . "{")
      (1070 . 16)
      (1010 0.0 0.0 0.0)
      (1010 0.0 0.0 1.0)
      (1040 . 0.0)
      (1040 . 674.431)
      (1040 . 4872.81)
      (1040 . -8802.63)
      (1040 . 50.0)
      (1040 . 0.0)
      (1040 . 0.0)
      (1070 . 0)
      (1070 . 1500)
      (1070 . 1)
      (1070 . 1)
      (1070 . 0)
      (1070 . 0)
      (1070 . 0)
      (1070 . 0)
      (1040 . 0.0)
      (1040 . 0.0)
      (1040 . 0.0)
      (1040 . 0.5)
      (1040 . 0.5)
      (1040 . 0.5)
      (1040 . 0.5)
      (1070 . 0)
      (1002 . "{")
      (1002 . "}")
      (1002 . "}")
      )
  )
)
--- End code ---

I can find the viewport zoom scale factor, but understand that that scale factor may or may not match the annotative scale.

Anyone else know how I can get the annotative scale from a viewport?

Thanks,
Mike

T.Willey:
You have to look in the extension dictionary (dxf code 360).  From there I forget, but you can check each object in the dictionary, as there shouldn't be too many.

mkweaver:

--- Quote from: T.Willey on April 23, 2008, 10:59:53 AM ---You have to look in the extension dictionary (dxf code 360).  From there I forget, but you can check each object in the dictionary, as there shouldn't be too many.

--- End quote ---

This got me looking in the right direction, which enabled me to create the following routine:


--- Code: ---;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;  Routine: GetPVPAnnoScale ;;;
;;;  Purpose: Retrieve the annotation scale factor for a paperspace viewport ;;;
;;;  Arguments: PVPent - ename, the entity name for a paperspace viewport ;;;
;;;  Returns: A list, thus: ;;;
;;;   car = the entity handle to the dictionary entry that contains ;;;
;;; the annotation scale factor. ;;;
;;;   cadr = the annotation scale factor for the viewport ;;;
;;;   caddr = the name of the annotation scale factor as shown in ;;;
;;;   the scale list. ;;;
;;;   nil is returned if the annotative property for the viewport ;;;
;;;     has not been set. ;;;
;;;-----------------------------------------------------------------------------;;;
;;;  Comments:  The entity handle is returned so that this information can be ;;;
;;; persisted. ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun GetPVPAnnoScale(PVPent / PVPDict DictList ScaleName ScaleFactor)
  (cond
    ;;This viewport's annotative scale has not been set.
    ((null (assoc 360 (setq PVPElist (entget PVPent))))
     nil
     )
    (T
     (setq
       PVPDict (entget (cdr (assoc 360 PVPElist)))
       DictList (entget (cdr (assoc 340 (entget (cdr (assoc 360 PVPDict))))))
       ScaleName (cdr (assoc 300 DictList))
       ScaleFactor(/ (cdr (assoc 141 DictList))(cdr (assoc 140 DictList)))
       )
     (list (cdr (assoc 5 DictList)) ScaleName ScaleFactor)
     )
    )
  )

--- End code ---

Which brings me to my next question, which addresses the question behind the question:  How to implement annotation scaling on existing drawings? Which will be the subject for another thread.

Navigation

[0] Message Index

Go to full version