CAD Forum - Database of tips, tricks and utilities for AutoCAD, Inventor and other Autodesk products []
Czech English Deutsch
 Visitors: 2400 
RSS tips RSS channel - CAD tips
RSS discussion RSS channel - CAD discussion

Discussion Discussion forum

HelpCAD discussion

CAD Forum - Homepage CAD discussion forum - ask any CAD-related questions here, share your CAD knowledge on AutoCAD, Inventor, Revit and other Autodesk software with your peers from all over the world. To start a new topic, choose an appropriate forum.

Please abide by the rules of this forum.

How to post questions: register or login, go to the specific forum and click the NEW TOPIC button.
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

The information that you provide in this form will make up your forum profile which can be viewed by other forum members. Your email address will only be visible by forum admin and moderators and will be used to send you Forum Notifications. To cancel your account, use the page Opt-out or contact

Topic ClosedChange linetype scale by a factor

 Post Reply Post Reply
csccsccsc View Drop Down

Joined: 14.Jul.2015
Location: Hong Kong
Using: 2008
Status: Offline
Points: 2
Direct Link To This Post Topic: Change linetype scale by a factor
    Posted: 14.Jul.2015 at 13:32

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!


;;Change linetype scale by a factor.

 (defun c:lsr ()

 (setq en (car (entsel))

       ed (entget en)

      lts (cdr (assoc 48 ed))


 (if (/= lts nil)


   (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)




   (entmod ed)

   (entupd en)



   (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) "")




Back to Top
TheWillCAD View Drop Down

Joined: 17.Jun.2015
Location: United States
Using: AutoCAD 2.18-Map2018
Status: Offline
Points: 3
Direct Link To This Post Posted: 20.Jul.2015 at 14:48
Here ya go:

;;Change linetype scale by a factor
;;Original version:
;;Modified by Will Garmer to work on selection set instead of single object 2015-07-20


;;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))

;;Do the deed
(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)
            (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
            (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))

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

Edited by TheWillCAD - 20.Jul.2015 at 14:50
Back to Top

Related CAD tips:

 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

This page was generated in 0,066 seconds.