Jump to content

Why will this (getvar 'dimscale) not work on windows 7?


Recommended Posts

Posted

This works just fine on the other computers but the 2 computers running windows 7 won't work. It's supposed to reat 1" = 20' when ran but it reads 1" = ' on the computers running 7

 

(defun c:dsc ()
(setq DS (rtos (getvar 'dimscale)))
(setq dwg-SCALE (substr DS 1 (- (strlen DS) 5)))
(SETQ DTE (STRCAT "1\" = " DWG-SCALE "'"))

 (if
   (and (not
          (eq (setq OldTxt "Scale") "")
        )
        (not
          (eq (setq NewTxt dte) "")
        )
   )
    (if (setq ss (ssget "x"
                        (list '(0 . "TEXT,MTEXT")
                              (cons 1 OldTxt)
                              (cons 410 (getvar 'ctab))
                        )
                 )
        )
      (repeat (setq in (sslength ss))
        (setq en (entget (ssname ss (setq in (1- in)))))
        (entmod (subst (cons 1 Newtxt) (assoc 1 en) en))
      )
    )
 )
)

Posted

It actually works with 1" = 20' but not any other. i.e. 1" = 30'

Posted

Ok so for some reason, when the dimscale is set at 20, everything works fine but when it's set to any other, 30, 40, 50, 60, 100, 200, I had to change the code from 5 - 3

 

(setq dwg-SCALE (substr DS 1 (- (strlen DS) 5)))

 

changed to

 

(setq dwg-SCALE (substr DS 1 (- (strlen DS) 3)))

 

what a beating. so now I have to have 2 commands to do the same thing. If you're using dimscale 20 then this if you're using dimscale 30, 40, 50, 60, 100 or 200, then another

 

here's my entire code

 

;INFO
(DEFUN C:INFO ()
(command ".osnap" "NOD,end,INT,CEN,mid")
(SETQ CL (GETVAR "CLAYER"))
(COMMAND "LAYER" "S" "LEGAL" "")
(setq me (getstring t "\nDrawn By: "))
 (if
   (and (not
          (eq (setq OldTxt "Drawn By") "")
        )
        (not
          (eq (setq NewTxt me) "")
        )
   )
    (if (setq ss (ssget "x"
                        (list '(0 . "TEXT,MTEXT")
                              (cons 1 OldTxt)
                              (cons 410 (getvar 'ctab))
                        )
                 )
        )
      (repeat (setq in (sslength ss))
        (setq en (entget (ssname ss (setq in (1- in)))))
        (entmod (subst (cons 1 Newtxt) (assoc 1 en) en))
      )
    )
 )

(setq DS (rtos (getvar 'dimscale)))
(setq dwg-SCALE (substr DS 1 (- (strlen DS) 5)))
(SETQ DTE (STRCAT "1\" = " DWG-SCALE "'"))

 (if
   (and (not
          (eq (setq OldTxt "Scale") "")
        )
        (not
          (eq (setq NewTxt dte) "")
        )
   )
    (if (setq ss (ssget "x"
                        (list '(0 . "TEXT,MTEXT")
                              (cons 1 OldTxt)
                              (cons 410 (getvar 'ctab))
                        )
                 )
        )
      (repeat (setq in (sslength ss))
        (setq en (entget (ssname ss (setq in (1- in)))))
        (entmod (subst (cons 1 Newtxt) (assoc 1 en) en))
      )
    )
 )

    (setq d (rtos (getvar "CDATE") 2 6)
         yr (substr d 3 2)
         mo (substr d 5 2)
        day (substr d 7 2)
    )
(SETQ DTE (STRCAT MO "/" DAY "/" YR))
 (if
   (and (not
          (eq (setq OldTxt "Date") "")
        )
        (not
          (eq (setq NewTxt dte) "")
        )
   )
    (if (setq ss (ssget "x"
                        (list '(0 . "TEXT,MTEXT")
                              (cons 1 OldTxt)
                              (cons 410 (getvar 'ctab))
                        )
                 )
        )
      (repeat (setq in (sslength ss))
        (setq en (entget (ssname ss (setq in (1- in)))))
        (entmod (subst (cons 1 Newtxt) (assoc 1 en) en))
      )
    )
 )
(setq GFN (getstring t "\nType the GF Number: "))
 (if
   (and (not
          (eq (setq OldTxt "GF#") "")
        )
        (not
          (eq (setq NewTxt gfn) "")
        )
   )
    (if (setq ss (ssget "x"
                        (list '(0 . "TEXT,MTEXT")
                              (cons 1 OldTxt)
                              (cons 410 (getvar 'ctab))
                        )
                 )
        )
      (repeat (setq in (sslength ss))
        (setq en (entget (ssname ss (setq in (1- in)))))
        (entmod (subst (cons 1 Newtxt) (assoc 1 en) en))
      )
    )
 )
(setq dwg-name (substr (getvar "dwgname") 1 (- (strlen (getvar "dwgname")) 4)))
 (if
   (and (not
          (eq (setq OldTxt "Job#") "")
        )
        (not
          (eq (setq NewTxt dwg-name) "")
        )
   )
    (if (setq ss (ssget "x"
                        (list '(0 . "TEXT,MTEXT")
                              (cons 1 OldTxt)
                              (cons 410 (getvar 'ctab))
                        )
                 )
        )
      (repeat (setq in (sslength ss))
        (setq en (entget (ssname ss (setq in (1- in)))))
        (entmod (subst (cons 1 Newtxt) (assoc 1 en) en))
      )
    )
 )
 (princ)
)

Posted (edited)

Ok so I'm working through this all by myself haha. I just added the code to look for the 1" = ' and replace also. Good talk guys. Good talk!

 

(setq DS (rtos (getvar 'dimscale)))
(setq dwg-SCALE (substr DS 1 (- (strlen DS) 5)))
(SETQ DTE (STRCAT "1\" = " DWG-SCALE "'"))

 (if
   (and (not
          (eq (setq OldTxt "Scale") "")
        )
        (not
          (eq (setq NewTxt dte) "")
        )
   )
    (if (setq ss (ssget "x"
                        (list '(0 . "TEXT,MTEXT")
                              (cons 1 OldTxt)
                              (cons 410 (getvar 'ctab))
                        )
                 )
        )
      (repeat (setq in (sslength ss))
        (setq en (entget (ssname ss (setq in (1- in)))))
        (entmod (subst (cons 1 Newtxt) (assoc 1 en) en))
      )
    )
 )

(setq DS7 (rtos (getvar 'dimscale)))
(setq dwg-SCALE (substr DS7 1 (- (strlen DS) 3)))
(SETQ DTE (STRCAT "1\" = " DWG-SCALE "'"))

 (if
   (and (not
          (eq (setq OldTxt "1\" = '") "")
        )
        (not
          (eq (setq NewTxt dte) "")
        )
   )
    (if (setq ss (ssget "x"
                        (list '(0 . "TEXT,MTEXT")
                              (cons 1 OldTxt)
                              (cons 410 (getvar 'ctab))
                        )
                 )
        )
      (repeat (setq in (sslength ss))
        (setq en (entget (ssname ss (setq in (1- in)))))
        (entmod (subst (cons 1 Newtxt) (assoc 1 en) en))
      )
    )
 )

Edited by clint0577

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...