Diesel Code for Viewport Scale Field Input

Diesel Code for Viewport Scale Field Input

kieran.leadbetter
Advocate Advocate
392 Views
5 Replies
Message 1 of 6

Diesel Code for Viewport Scale Field Input

kieran.leadbetter
Advocate
Advocate

Hello

So I've set up a fully automated titleblock and script automation for a series of drawings, one issue though which I can't seem to automate the scale field

I know I can do this:

Attribute Editor
Insert Field
Field Category: Object
Object
Select Object
Select Viewport
 - Custom Scale (Use Scale Name) or 1:#

And this will work to show either the scale name or whatever the scale currently is, but the way my plotting is setup, I print and annotate as if they were A3, but work in an A1 paperspace due to the drawings I recieve and they use A1 formatting and that when I print at A3 Plotting it comes out at a slightly less accurate quality than A1 plotting

So what I need is either a diesel code or a field, which will Show what the scale is at half the ratio

So the viewport is 1:100, I need the titleblock to say 1:50
Or if it is 1:50, I need it to show 1:25

Does anyone know of a way to achieve this




0 Likes
393 Views
5 Replies
Replies (5)
Message 2 of 6

pendean
Community Legend
Community Legend
DIESEL cannot do that on its own on the fly as part of the PLOT process: neither can a FIELD. sorry.
Are you an LT user by chance?
0 Likes
Message 3 of 6

kieran.leadbetter
Advocate
Advocate

No I'm a full version user

I know that if I rename and alter the scale units, so that the scale says 1:100, but the actual scale used is 1:200, the 1:2 ratio issue would cancel out

Only thing with this is I can see it causing confusion for people down the line

0 Likes
Message 4 of 6

pendean
Community Legend
Community Legend
@kieran.leadbetter Oh I totally understand the need, but to be honest no one in our offices treat PDFs like old-school paper prints anymore: we issue actual size PDFs to everyone, leave it up to the recipient to decide how to scale it down (or up) themselves to fit there needs, we add scale bars and print-scales with clarification on actual sheet size on it.

Make the switch: you're not paper-printing anymore.
0 Likes
Message 5 of 6

paullimapa
Mentor
Mentor

best to just include a graphic scale in all plotted pdf and problem solved


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 6 of 6

CADaSchtroumpf
Advisor
Advisor

A start with this?

(defun make_field (obj p / nw_obj)
  (setq
    nw_obj
    (vla-addMtext Space
      (vlax-3d-point p)
      0.0
      (strcat
        "{\\fArial|b0|i0|c0|p34;"
        "%<\\AcVar ctab>%"
        " - Scale 1/"
        "%<\\AcExpr (1000/"
        "%<\\AcObjProp Object(%<\\_ObjId "
        (itoa (vla-get-ObjectID (vlax-ename->vla-object obj)))
        ">%).CustomScale \\f \"%lu2%qf2816\">%"
        ") \\f \"%lu2%pr0\">%"
      )
    )
  )
  (mapcar
    '(lambda (pr val)
      (vlax-put nw_obj pr val)
    )
    (list 'AttachmentPoint 'Height 'DrawingDirection 'InsertionPoint 'StyleName 'Layer 'Rotation 'BackgroundFill)
    (list 7 3.5 5 p "Standard" "0" 0.0 -1)
  )
)
(defun c:Field_Layout_Scale ( / el AcDoc Space js n ent dxf_ent pt_v l h pt)
  (vl-load-com)
  (foreach el (layoutlist)
    (setvar "CTAB" el)
    (setq
      AcDoc (vla-get-ActiveDocument (vlax-get-acad-object))
      Space (vla-get-PaperSpace AcDoc)
    )
    (setq js
      (ssget "_X"
        (list
          '(0 . "VIEWPORT")
          '(67 . 1)
          (cons 410 el)
          '(-4 . "!=")
          '(69 . 1)
        )
      )
    )
    (repeat (setq n (sslength js))
      (setq
        pt_v (cdr (assoc 10 (setq dxf_ent (entget (setq ent (ssname js (setq n (1- n))))))))
        l (cdr (assoc 40 dxf_ent))
        h (cdr (assoc 41 dxf_ent))
        pt (list (- (car pt_v) (* 0.5 l)) (- (cadr pt_v) (* 0.5 h)) 0.0)
      )
      (make_field ent pt)
    )
  )
  (prin1)
)
0 Likes