CAD Forum - Database of tips, tricks and utilities for AutoCAD, Inventor and other Autodesk products [www.cadforum.cz]
Czech English Deutsch
Login/Register:
 Visitors: 5176 
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 webmaster@cadforum.cz.

Topic ClosedChange linetype scale by a factor

 Post Reply Post Reply
Author
csccsccsc View Drop Down
Newbie
Newbie


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

)

Back to Top
TheWillCAD View Drop Down
Newbie
Newbie


Joined: 17.Jun.2015
Location: United States
Using: AutoCAD 2.18-Map2014
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: 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



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,078 seconds.