Print Page | Close Window

Change linetype scale by a factor

Printed From: CAD Forum
Category: EN
Forum Name: AutoCAD
Forum Description: Discussion about AutoCAD and AutoCAD LT, viewers, DWG and DWF formats, Design Review, AutoCAD 360, add-ons
URL: https://www.cadforum.cz/forum_en/forum_posts.asp?TID=11259
Printed Date: 31.May.2026 at 22:17


Topic: Change linetype scale by a factor
Posted By: csccsccsc
Subject: Change linetype scale by a factor
Date Posted: 14.Jul.2015 at 13:32
Hi,

I am searching a lisp to change linetype scale by a factor. And I found the following code. However, it only works with a single object. Is is possible to modify it so that it can work with multiple objects? Thank you very much!

Chan

;;Change linetype scale by a factor.

 (defun c:lsr ()

 (setq en (car (entsel))

       ed (entget en)

      lts (cdr (assoc 48 ed))

 )

 (if (/= lts nil)

  (progn

   (setq ns (getreal (strcat "\nScale linetype what factor of current scale? Current scale: <"(rtos lts)">. "))

        ns2 (* (/ ns ) lts)

   )

   (setq ed

       (subst (cons 48 ns2)

              (assoc 48 ed)

              ed

       )

   )

   (entmod ed)

   (entupd en)

  );progn

  (progn

   (setq ns (getreal (strcat "\nScale linetype to what factor of current scale? Current scale: <"(rtos 1)">."))

        ns2 (* (/ ns ) 1)

   )  

   (command "change" en "" "p" "s" (rtos ns2) "")

  )

 );if

)




Replies:
Posted By: TheWillCAD
Date Posted: 20.Jul.2015 at 14:48
Here ya go:


;;Change linetype scale by a factor
;;Original version: http://www.cadforum.cz/forum_en/forum_posts.asp?TID=11259&title=change-linetype-scale-by-a-factor
;;Modified by Will Garmer to work on selection set instead of single object 2015-07-20

(defun C:LSR (/ SS LTS_FAC COUNT OLD_VAL NEW_VAL E PROP_NUM)

;;=====================================================================================
;;Main body of C:LSR

;;Get the Selection Set
(setq SS (ssget))

;;Get the scale factor
(if (not OLD_LTS_FAC) (setq OLD_LTS_FAC 1))
(setq LTS_FAC (getreal (strcat "\nMultiply LinetypeScale of selected objects by what factor? <" (rtos OLD_LTS_FAC) ">. ")))
(if (= LTS_FAC nil) (setq LTS_FAC OLD_LTS_FAC))
(setq OLD_LTS_FAC LTS_FAC)

;;Do the deed
(terpri)
(setq COUNT 0)
(while    (< COUNT (sslength SS))
        (princ (strcat "\n--> Processing entity no.:" (itoa (+ 1 COUNT)) " of " (itoa (sslength SS)) "... "))
        (setq E (entget (ssname SS COUNT)))
        ;IF the object already has a ltscale
        ;THEN multiply it by the factor
        ;ELSE set the new scale equal to the factor
        (if    (assoc 48 E)
            ;THEN
            (progn    (setq OLD_VAL (cdr (assoc 48 E)) NEW_VAL (* LTS_FAC OLD_VAL))
                    (setq E (subst (cons PROP_NUM PROP_VAL) (assoc PROP_NUM E) E))
                    (entmod E)
                    (entupd (ssname SS COUNT))
            );progn THEN
           
            ;ELSE
            (progn    (setq NEW_VAL (cons 48 LTS_FAC))
                    (setq E (append E (list NEW_VAL)))
                    (entmod E)
                    (entupd (ssname SS COUNT))
            );progn ELSE
        );end if

        ;Increase the count by one to move on to the next object
        (setq COUNT (+ COUNT 1))
);while

;End the program gracefully
(prompt (strcat "\nEntity LinetypeScale of **" (itoa (sslength SS)) "** selected objects scaled by a factor of <" (rtos LTS_FAC) ">. "))
(princ)
);defun C:LSR




Print Page | Close Window