Jump to content

Recommended Posts

Posted

Our office has a lisp routine which can tell the user what the current drawing scale is, aptly named DWG_SCAL. It works in conjuction with the tracewid factor. We have been using this for years and love it. Granted, it was created before annotation evolved but we are still "holding on". I am trying to update our Section Title and Typical Detail blocks to include fields such as filename, originator, etc. I would like to include our DWG_SCAL lisp routine as a field but am not sure if the code written for the lisp routine works for "field code". Is it possible to use a lisp routine as a field? If so, how?

:?

Posted

Assuming that your lisp routine sets the drawing scale as a variable, create a Field using LispVariable as the Field Name.

or

Create a Field > Object > Object type (select Viewport) > Custom Scale

Posted
Assuming that your lisp routine sets the drawing scale as a variable, create a Field using LispVariable as the Field Name.

or

Create a Field > Object > Object type (select Viewport) > Custom Scale

 

You will need the variable to be global, else it will be set to nil when the LISP function completes. :wink:

Posted

Forgive my ignorance but when I choose the lispvariable field category I only have a few different lisp variables to select. What exactly do I need to select?

Posted
Forgive my ignorance but when I choose the lispvariable field category I only have a few different lisp variables to select. What exactly do I need to select?

 

Would you be able to post your LISP code - the variable would be the one that is bound to the drawing scale, but without seeing the LISP, it is impossible to know what that variable is called. :)

Posted

Use can use

 <Your code goes here> [/ code] tags to get around the smiley issue.

You can either select the LISP Variable: DWG_SC from the LispVariable section of the FIELDS dialog, or, this should insert it for you:

[code]
(defun c:fld  (/ Scale pt doc spc)
 (vl-load-com)
 (if (and (SETQ SCALE (GETVAR "TRACEWID"))
          (cond ((= scale 192)
                 (setq DWG_SC "SCALE\042 = 1/16\042 = 1'-0"))
                ((= scale 128)
                 (setq DWG_SC "SCALE\042 = 3/32\042 = 1'-0"))
                ((= scale 96)
                 (setq DWG_SC "SCALE\042 = 1/8\042 = 1'-0"))
                ((= scale 64)
                 (setq DWG_SC "SCALE\042 = 3/16\042 = 1'-0"))
                ((= scale 48)
                 (setq DWG_SC "SCALE\042 = 1/4\042 = 1'-0"))
                ((= scale 32)
                 (setq DWG_SC "SCALE\042 = 3/8\042 = 1'-0"))
                ((= scale 24)
                 (setq DWG_SC "SCALE\042 = 1/2\042 = 1'-0"))
                ((= scale 16)
                 (setq DWG_SC "SCALE\042 = 3/4\042 = 1'-0"))
                ((= scale 12)
                 (setq DWG_SC "SCALE\042 = 1\042 = 1'-0"))
                ((= scale 
                 (setq DWG_SC "SCALE\042 = 1 1/2\042 = 1'-0"))
                ((= scale 4)
                 (setq DWG_SC "SCALE\042 = 3\042 = 1'-0"))
                ((= scale 2)
                 (setq DWG_SC "SCALE\042 = 6\042 = 1'-0"))
                ((= scale 1)
                 (setq DWG_SC "FULL SCALE"))
                ((<= SCALE 0.99)
                 (SETQ DWG_SC "TRACEWID IS NOT SET"))
                (t nil))
          (setq pt (getpoint "\nSelect Point for Field: ")))
   (progn
     (setq doc (vla-get-ActiveDocument
                 (vlax-get-Acad-Object))
           spc (if (zerop (vla-get-activespace doc))
                 (if (= (vla-get-mspace doc) :vlax-true)
                   (vla-get-modelspace doc)
                   (vla-get-paperspace doc))
                 (vla-get-modelspace doc)))
     (vla-addMText spc
       (vlax-3D-point pt) 0
       "%<\\AcVar.17.0 Lisp.dwg_sc>%")))
 (princ))

Posted
Use can use
 <Your code goes here> [/ code] tags to get around the smiley issue.

You can either select the LISP Variable: DWG_SC from the LispVariable section of the FIELDS dialog, or, this should insert it for you:

[code]
(defun c:fld  (/ Scale pt doc spc)
 (vl-load-com)
 (if (and (SETQ SCALE (GETVAR "TRACEWID"))
          (cond ((= scale 192)
                 (setq DWG_SC "SCALE\042 = 1/16\042 = 1'-0"))
                ((= scale 128)
                 (setq DWG_SC "SCALE\042 = 3/32\042 = 1'-0"))
                ((= scale 96)
                 (setq DWG_SC "SCALE\042 = 1/8\042 = 1'-0"))
                ((= scale 64)
                 (setq DWG_SC "SCALE\042 = 3/16\042 = 1'-0"))
                ((= scale 48)
                 (setq DWG_SC "SCALE\042 = 1/4\042 = 1'-0"))
                ((= scale 32)
                 (setq DWG_SC "SCALE\042 = 3/8\042 = 1'-0"))
                ((= scale 24)
                 (setq DWG_SC "SCALE\042 = 1/2\042 = 1'-0"))
                ((= scale 16)
                 (setq DWG_SC "SCALE\042 = 3/4\042 = 1'-0"))
                ((= scale 12)
                 (setq DWG_SC "SCALE\042 = 1\042 = 1'-0"))
                ((= scale 
                 (setq DWG_SC "SCALE\042 = 1 1/2\042 = 1'-0"))
                ((= scale 4)
                 (setq DWG_SC "SCALE\042 = 3\042 = 1'-0"))
                ((= scale 2)
                 (setq DWG_SC "SCALE\042 = 6\042 = 1'-0"))
                ((= scale 1)
                 (setq DWG_SC "FULL SCALE"))
                ((<= SCALE 0.99)
                 (SETQ DWG_SC "TRACEWID IS NOT SET"))
                (t nil))
          (setq pt (getpoint "\nSelect Point for Field: ")))
   (progn
     (setq doc (vla-get-ActiveDocument
                 (vlax-get-Acad-Object))
           spc (if (zerop (vla-get-activespace doc))
                 (if (= (vla-get-mspace doc) :vlax-true)
                   (vla-get-modelspace doc)
                   (vla-get-paperspace doc))
                 (vla-get-modelspace doc)))
     (vla-addMText spc
       (vlax-3D-point pt) 0
       "%<\\AcVar.17.0 Lisp.dwg_sc>%")))
 (princ))

 

Okay, the field loaded but when I insert the block into a new drawing instead of the attribute reading as the current scale it looks like this, ####

Posted
Use can use
 <Your code goes here> [/ code] tags to get around the smiley issue.

You can either select the LISP Variable: DWG_SC from the LispVariable section of the FIELDS dialog, or, this should insert it for you:

[code]
(defun c:fld  (/ Scale pt doc spc)
 (vl-load-com)
 (if (and (SETQ SCALE (GETVAR "TRACEWID"))
          (cond ((= scale 192)
                 (setq DWG_SC "SCALE\042 = 1/16\042 = 1'-0"))
                ((= scale 128)
                 (setq DWG_SC "SCALE\042 = 3/32\042 = 1'-0"))
                ((= scale 96)
                 (setq DWG_SC "SCALE\042 = 1/8\042 = 1'-0"))
                ((= scale 64)
                 (setq DWG_SC "SCALE\042 = 3/16\042 = 1'-0"))
                ((= scale 48)
                 (setq DWG_SC "SCALE\042 = 1/4\042 = 1'-0"))
                ((= scale 32)
                 (setq DWG_SC "SCALE\042 = 3/8\042 = 1'-0"))
                ((= scale 24)
                 (setq DWG_SC "SCALE\042 = 1/2\042 = 1'-0"))
                ((= scale 16)
                 (setq DWG_SC "SCALE\042 = 3/4\042 = 1'-0"))
                ((= scale 12)
                 (setq DWG_SC "SCALE\042 = 1\042 = 1'-0"))
                ((= scale 
                 (setq DWG_SC "SCALE\042 = 1 1/2\042 = 1'-0"))
                ((= scale 4)
                 (setq DWG_SC "SCALE\042 = 3\042 = 1'-0"))
                ((= scale 2)
                 (setq DWG_SC "SCALE\042 = 6\042 = 1'-0"))
                ((= scale 1)
                 (setq DWG_SC "FULL SCALE"))
                ((<= SCALE 0.99)
                 (SETQ DWG_SC "TRACEWID IS NOT SET"))
                (t nil))
          (setq pt (getpoint "\nSelect Point for Field: ")))
   (progn
     (setq doc (vla-get-ActiveDocument
                 (vlax-get-Acad-Object))
           spc (if (zerop (vla-get-activespace doc))
                 (if (= (vla-get-mspace doc) :vlax-true)
                   (vla-get-modelspace doc)
                   (vla-get-paperspace doc))
                 (vla-get-modelspace doc)))
     (vla-addMText spc
       (vlax-3D-point pt) 0
       "%<\\AcVar.17.0 Lisp.dwg_sc>%")))
 (princ))

 

Okay, I got it to work but instead of the field just giving the current scale it adds Scale" in front of the scale, for example: SCALE" = 3/4" = 1'-0". Is there a way for the field attribute to only read 3/4" = 1'-0"?

Posted

That's only what you had before.

 

I have changed your original code to remove the "SCALE"

 

(defun c:fld  (/ Scale pt doc spc)
 (vl-load-com)
 (if (and (SETQ SCALE (GETVAR "TRACEWID"))
          (cond ((= scale 192)
                 (setq DWG_SC [color=Red][b]"1/16\042 = 1'-0"[/b][/color]))
                ((= scale 128)
                 (setq DWG_SC [b][color=Red]"3/32\042 = 1'-0"[/color][/b]))
                ((= scale 96)
                 (setq DWG_SC [b][color=Red]"1/8\042 = 1'-0"[/color][/b]))
                ((= scale 64)
                 (setq DWG_SC [color=Red][b]"3/16\042 = 1'-0"[/b][/color]))
                ((= scale 48)
                 (setq DWG_SC [b][color=Red]"1/4\042 = 1'-0"[/color][/b]))
                ((= scale 32)
                 (setq DWG_SC [b][color=Red]"3/8\042 = 1'-0"[/color][/b]))
                ((= scale 24)
                 (setq DWG_SC [b][color=Red]"1/2\042 = 1'-0"[/color][/b]))
                ((= scale 16)
                 (setq DWG_SC [b][color=Red]"3/4\042 = 1'-0"[/color][/b]))
                ((= scale 12)
                 (setq DWG_SC [b][color=Red]"1\042 = 1'-0"[/color][/b]))
                ((= scale 
                 (setq DWG_SC [color=Red][b]"1 1/2\042 = 1'-0"[/b][/color]))
                ((= scale 4)
                 (setq DWG_SC [color=Red][b]"3\042 = 1'-0"[/b][/color]))
                ((= scale 2)
                 (setq DWG_SC [b][color=Red]"6\042 = 1'-0"[/color][/b]))
                ((= scale 1)
                 (setq DWG_SC "FULL SCALE"))
                ((<= SCALE 0.99)
                 (SETQ DWG_SC "TRACEWID IS NOT SET"))
                (t nil))
          (setq pt (getpoint "\nSelect Point for Field: ")))
   (progn
     (setq doc (vla-get-ActiveDocument
                 (vlax-get-Acad-Object))
           spc (if (zerop (vla-get-activespace doc))
                 (if (= (vla-get-mspace doc) :vlax-true)
                   (vla-get-modelspace doc)
                   (vla-get-paperspace doc))
                 (vla-get-modelspace doc)))
     (vla-addMText spc
       (vlax-3D-point pt) 0
       "%<\\AcVar.17.0 Lisp.dwg_sc>%")))
 (princ))

Posted
That's only what you had before.

 

I have changed your original code to remove the "SCALE"

 

(defun c:fld  (/ Scale pt doc spc)
 (vl-load-com)
 (if (and (SETQ SCALE (GETVAR "TRACEWID"))
          (cond ((= scale 192)
                 (setq DWG_SC [color=red][b]"1/16\042 = 1'-0"[/b][/color]))
                ((= scale 128)
                 (setq DWG_SC [b][color=red]"3/32\042 = 1'-0"[/color][/b]))
                ((= scale 96)
                 (setq DWG_SC [b][color=red]"1/8\042 = 1'-0"[/color][/b]))
                ((= scale 64)
                 (setq DWG_SC [color=red][b]"3/16\042 = 1'-0"[/b][/color]))
                ((= scale 48)
                 (setq DWG_SC [b][color=red]"1/4\042 = 1'-0"[/color][/b]))
                ((= scale 32)
                 (setq DWG_SC [b][color=red]"3/8\042 = 1'-0"[/color][/b]))
                ((= scale 24)
                 (setq DWG_SC [b][color=red]"1/2\042 = 1'-0"[/color][/b]))
                ((= scale 16)
                 (setq DWG_SC [b][color=red]"3/4\042 = 1'-0"[/color][/b]))
                ((= scale 12)
                 (setq DWG_SC [b][color=red]"1\042 = 1'-0"[/color][/b]))
                ((= scale 
                 (setq DWG_SC [color=red][b]"1 1/2\042 = 1'-0"[/b][/color]))
                ((= scale 4)
                 (setq DWG_SC [color=red][b]"3\042 = 1'-0"[/b][/color]))
                ((= scale 2)
                 (setq DWG_SC [b][color=red]"6\042 = 1'-0"[/color][/b]))
                ((= scale 1)
                 (setq DWG_SC "FULL SCALE"))
                ((<= SCALE 0.99)
                 (SETQ DWG_SC "TRACEWID IS NOT SET"))
                (t nil))
          (setq pt (getpoint "\nSelect Point for Field: ")))
   (progn
     (setq doc (vla-get-ActiveDocument
                 (vlax-get-Acad-Object))
           spc (if (zerop (vla-get-activespace doc))
                 (if (= (vla-get-mspace doc) :vlax-true)
                   (vla-get-modelspace doc)
                   (vla-get-paperspace doc))
                 (vla-get-modelspace doc)))
     (vla-addMText spc
       (vlax-3D-point pt) 0
       "%<\\AcVar.17.0 Lisp.dwg_sc>%")))
 (princ))

 

I really appreciate your assistance and thanks for being patient but it still reads SCALE" = 1/2" = 1'-0".

Posted
I really appreciate your assistance and thanks for being patient but it still reads SCALE" = 1/2" = 1'-0".

 

This does not happen for me - have you closed the current drawing and reloaded the LISP file?

Posted
Use can use
 <Your code goes here> [/ code] tags to get around the smiley issue.

You can either select the LISP Variable: DWG_SC from the LispVariable section of the FIELDS dialog, or, this should insert it for you:

[code]
(defun c:fld  (/ Scale pt doc spc)
 (vl-load-com)
 (if (and (SETQ SCALE (GETVAR "TRACEWID"))
          (cond ((= scale 192)
                 (setq DWG_SC "SCALE\042 = 1/16\042 = 1'-0"))
                ((= scale 128)
                 (setq DWG_SC "SCALE\042 = 3/32\042 = 1'-0"))
                ((= scale 96)
                 (setq DWG_SC "SCALE\042 = 1/8\042 = 1'-0"))
                ((= scale 64)
                 (setq DWG_SC "SCALE\042 = 3/16\042 = 1'-0"))
                ((= scale 48)
                 (setq DWG_SC "SCALE\042 = 1/4\042 = 1'-0"))
                ((= scale 32)
                 (setq DWG_SC "SCALE\042 = 3/8\042 = 1'-0"))
                ((= scale 24)
                 (setq DWG_SC "SCALE\042 = 1/2\042 = 1'-0"))
                ((= scale 16)
                 (setq DWG_SC "SCALE\042 = 3/4\042 = 1'-0"))
                ((= scale 12)
                 (setq DWG_SC "SCALE\042 = 1\042 = 1'-0"))
                ((= scale 
                 (setq DWG_SC "SCALE\042 = 1 1/2\042 = 1'-0"))
                ((= scale 4)
                 (setq DWG_SC "SCALE\042 = 3\042 = 1'-0"))
                ((= scale 2)
                 (setq DWG_SC "SCALE\042 = 6\042 = 1'-0"))
                ((= scale 1)
                 (setq DWG_SC "FULL SCALE"))
                ((<= SCALE 0.99)
                 (SETQ DWG_SC "TRACEWID IS NOT SET"))
                (t nil))
          (setq pt (getpoint "\nSelect Point for Field: ")))
   (progn
     (setq doc (vla-get-ActiveDocument
                 (vlax-get-Acad-Object))
           spc (if (zerop (vla-get-activespace doc))
                 (if (= (vla-get-mspace doc) :vlax-true)
                   (vla-get-modelspace doc)
                   (vla-get-paperspace doc))
                 (vla-get-modelspace doc)))
     (vla-addMText spc
       (vlax-3D-point pt) 0
       "%<\\AcVar.17.0 Lisp.dwg_sc>%")))
 (princ))

 

Hi.....Why use TRACEWID?? Why not CANNOSCALE?? just wondering.

 

T2L

Posted
Hi.....Why use TRACEWID?? Why not CANNOSCALE?? just wondering.

 

T2L

 

I'm just manipulating the old routine. o:)

Posted
This does not happen for me - have you closed the current drawing and reloaded the LISP file?

 

You are a genius!!!!! I had to close AutoCAD completely and reload the lisp routines but once I did that everything seems to be working fine!

 

THANK YOU SO MUCH FOR YOUR ASSISTANCE!

 

:D:D:D:D:D:D:D

Posted
You are a genius!!!!! I had to close AutoCAD completely and reload the lisp routines but once I did that everything seems to be working fine!

 

THANK YOU SO MUCH FOR YOUR ASSISTANCE!

 

:D:D:D:D:D:D:D

 

 

No problem - happy to help :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...