Jump to content

Change a linear scale?


lucas3

Recommended Posts

Change a linear scale by region, why have err? Parameter type error:stringp (8 . "0")

(defun c:TT (/ e d el lay lt l nls ss)
 (if (and (setq ss (ssget)) ;_Do not choose Continuous
   (setq d (getdist "\nSpecifies the length : ")) ;_
     )
   (progn
     (setq nls (getvar "ltscale"))
     (repeat (setq n (sslength ss))
(setq e	  (ssname ss (setq n (1- n)))
      el  (entget e)
      lay (assoc 8 el)
)
(if (not (setq lt (cdr (assoc 6 el)))) ;
  (setq lt (cdr (assoc 6 (tblsearch "layer" lay)))) ;
)
(setq l (cdr (assoc 40 (tblsearch "ltype" lt)))) ;_
(vl-catch-all-apply
  'vlax-put-property
  (list (vlax-ename->vla-object e) 'LinetypeScale (/ d l nls))
)
     )
   )
 )
 (princ)
)
(princ "\nCommand:TT")

Edited by lucas3
Link to comment
Share on other sites

  • Replies 37
  • Created
  • Last Reply

Top Posters In This Topic

  • lucas3

    18

  • Tharwat

    5

  • eldon

    4

  • flyfox1047

    4

Top Posters In This Topic

Posted Images

I am not quite sure why you want to post this thread in the Lisp section :shock:

 

Have you tried the Ltscale command, if you want to change the scale for the whole drawing?

 

Have you tried different Linetypes, i.e. CENTRE, CENTRE2, CENTREX2, DASHED, DASHED2, DASHEDX2 which are all available as standard.

 

Have you tried changing the Ltscale for lines in their Properties?

 

Have you tried all these things yet?

Link to comment
Share on other sites

I am not quite sure why you want to post this thread in the Lisp section :shock:

 

Have you tried the Ltscale command, if you want to change the scale for the whole drawing?

 

Have you tried different Linetypes, i.e. CENTRE, CENTRE2, CENTREX2, DASHED, DASHED2, DASHEDX2 which are all available as standard.

 

Have you tried changing the Ltscale for lines in their Properties?

 

Have you tried all these things yet?

 

I know that " Ltscale ,This is for Global

Link to comment
Share on other sites

I know that a lisp can change "individual object ltscale" & "overall ltscale" ,but my idea is different from this, I want: 1.multi-select(region) 2.Input the scaling factor or Automatic judgment。

 

;;; dynamic  by qjchen@gmail.com
;;; The mail idea come from eachy master:  http://eachy.bokee.com/5731665.html
;;; http://www.xdcad.net/forum/showthread.php?postid=1534283

(defun C:test ( / dcl_id dclcontent dclname userclick temp)
 (vl-load-com)
 (setq temp (getvar "cmdecho"))
 (setvar "cmdecho" 0)
 (command "undo" "be")
 (setq dclcontent (list 
          "qjchenedynamicltscale:dialog{"
          "label=\"dynamic linetype scale modify by qjchen\";"
          ":button{" 
               "key = \"button1\";"
               "label = \"individual object ltscale\";}"
          ":button{" 
               "key = \"button2\";"
               "label = \"overall ltscale\";}"
          "ok_cancel;}")
 dclname "qjchendltscale"
 )
 (setq dcl_id (load_dialog (qjchencreatdcl dclname dclcontent))) 
 (if (not (new_dialog "qjchenedynamicltscale" dcl_id)) (exit))
 (action_tile "button1" "(done_dialog 3)")
 (action_tile "button2" "(done_dialog 4)")
 (setq userclick (start_dialog))
 (unload_dialog dcl_id)
 (cond ((= 3 userclick)(qjchenedltscale 1))
       ((= 4 userclick)(qjchenedltscale 2))
 )
 (command "undo" "e")
 (setvar "cmdecho" temp)
)

(defun qjchenedltscale(n / a b gr linetype newscale o orilst overallltscale zq)
 (prompt "\n Please select one not continuous linetype object:")
 (setq a (car (entsel)) o (vlax-ename->vla-object a))
 (setq orilst (vlax-get-property o 'LinetypeScale))
 (setq linetype (cdr (assoc 6 (entget a))))
 (if (= linetype nil) 
     (setq linetype (cdr (assoc 6 (tblsearch "layer" (cdr (assoc 8 (entget a)))))))
 )
 (if (and linetype (/= linetype "Continuous"))
   (progn  
     (setq zq (cdr (assoc 40 (tblsearch "ltype" linetype))))
     (setq overallltscale (getvar "LTSCALE"))
     (setq b (getpoint "\nSelect one point:"))
     (while (= (car (setq gr (grread nil 5 0))) 5)
       (redraw)
       (grdraw (cadr gr) b 1 1)
       (setq newscale (/ (distance (cadr gr) b) zq overallltscale))
       (apply-props o (list (list "LinetypeScale" newscale)))
     )
     (if (= n 2)
       (progn
         (setvar "ltscale" (* overallltscale (/ newscale orilst)))
         (apply-props o (list (list "LinetypeScale" orilst)))
         (command "regen")
       )
     )
   )
 )
 (vlax-release-object o)
 (princ)
)

;;from dave theswamp
(defun apply-props (object proplist)
 (foreach prop proplist
   (if (vlax-property-available-p object (car prop))
     (vlax-put-property object (car prop) (cadr prop))
   )
 )
)

(defun qjchencreatdcl(dclname lst)
(setq dcl_name (strcat (getenv "temp") "\\" dclname ".dcl")
       f (OPEN dcl_name "w")
 )
 (foreach x lst
    (write-line x f)
  )
 (close f)
 dcl_name
)

;;end main program
(princ "\n By qjchen@gmail.com, dynamic linescale, The command is test")
(princ)

Link to comment
Share on other sites

Can't you do that with the Properties dialog box?

 

If you have a lisp for everything, then you get divorced from knowing how AutoCAD works. Also you will have trouble remembering all your lisps as well as the conventional commands.

 

It is possible to write a lisp yourself, once you learn. Then you are increasing your knowledge.

 

There are other solutions like making new layers and then assigning new linetypes to them. These linetypes you can scale how you want, and then you would have learnt how to create Linetypes. So many things for you to do yourself.

Link to comment
Share on other sites

(defun c:TT (/ e d el lay lt l nls ss)
 (if (and (setq ss (ssget)) ;_Do not choose Continuous
   (setq d (getdist "\nSpecifies the length : ")) ;_
     )
   (progn
     (setq nls (getvar "ltscale"))
     (repeat (setq n (sslength ss))
(setq e	  (ssname ss (setq n (1- n)))
      el  (entget e)
      lay (assoc 8 el)
)
(if (not (setq lt (cdr (assoc 6 el)))) ;
  (setq lt (cdr (assoc 6 (tblsearch "layer" lay)))) ;
)
(setq l (cdr (assoc 40 (tblsearch "ltype" lt)))) ;_
(vl-catch-all-apply
  'vlax-put-property
  (list (vlax-ename->vla-object e) 'LinetypeScale (/ d l nls))
)
     )
   )
 )
 (princ)
)
(princ "\nCommand:TT")

 

Why ? have err

Link to comment
Share on other sites

1.multi-select(region) 2.Input the scaling factor or Automatic judgment。

 

How is the "region" being defined? You are aware that there is a REGION command in AutoCAD which in this case I don't think it is what you are referring to or is it?

 

How does the lisp routine determine on its own (automatic judgement) what the linetype scale for any particular object should be?

 

I think you have created a whole new discipline called fuzzy lisp.

Link to comment
Share on other sites

How does the lisp routine determine on its own (automatic judgement) what the linetype scale for any particular object should be?

 

It could be with this lisp ;)

 

Be SURE to have the selected lines on any hidden Ltypes to see the changes .

 

(defun c:Test (/ ss l n e)
 ;;    Tharwat 02.01.2014    ;;
 (if (and (setq ss (ssget "_:L" '((0 . "*LINE")))) (setq l (getdist "\n Specify Line Type Scale :")))
   (repeat (setq n (sslength ss))
     (setq e (entget (ssname ss (setq n (1- n)))))
     (entmod (append e (list (cons 48 l))))
   )
 )
 (princ)
)

Link to comment
Share on other sites

1.multi-select(region) 2.Input the scaling factor or Automatic judgment。

 

How is the "region" being defined? You are aware that there is a REGION command in AutoCAD which in this case I don't think it is what you are referring to or is it?

 

How does the lisp routine determine on its own (automatic judgement) what the linetype scale for any particular object should be?

 

I think you have created a whole new discipline called fuzzy lisp.

 

First, my english is very poor!

2.region choose is mean:Drag the mouse choose

3.automatic judgement,look this GIF photo

22.gif

Link to comment
Share on other sites

Yes, sometimes things get lost in translation. Unfortunately that cannot be helped. That is why I asked for more details and/or a drawing.

 

Sorry but I cannot open your attachment.

Link to comment
Share on other sites

Yes, sometimes things get lost in translation. Unfortunately that cannot be helped. That is why I asked for more details and/or a drawing.

 

Sorry but I cannot open your attachment.

 

GIF photo is reupload thank!

Link to comment
Share on other sites

It could be with this lisp ;)

 

Be SURE to have the selected lines on any hidden Ltypes to see the changes .

 

(defun c:Test (/ ss l n e)
 ;;    Tharwat 02.01.2014    ;;
 (if (and (setq ss (ssget "_:L" '((0 . "*LINE")))) (setq l (getdist "\n Specify Line Type Scale :")))
   (repeat (setq n (sslength ss))
     (setq e (entget (ssname ss (setq n (1- n)))))
     (entmod (append e (list (cons 48 l))))
   )
 )
 (princ)
)

 

 

Thank you very much !Tharwat ,very good ! Automatically adjust the linear scale,can do ? look this photo:

22.gif

Link to comment
Share on other sites

Thank you very much !Tharwat ,very good ! Automatically adjust the linear scale,can do ? look this photo:

 

Does it mean that you are satisfied with the routine or what ?

Link to comment
Share on other sites

Does it mean that you are satisfied with the routine or what ?

 

Thank you ! Tharwat ,You answered my question correctly!If can automatically adjust will be better

(defun c:Test (/ ss l n e)
 ;;    Tharwat 02.01.2014    ;;
 (if (and (setq ss (ssget "_:L" '((0 . "*LINE")))) (setq l (getdist "\n Specify Line Type Scale :")))
   (repeat (setq n (sslength ss))
     (setq e (entget (ssname ss (setq n (1- n)))))
     (entmod (append e (list (cons 48 l))))
   )
 )
 (princ)
)

 

Can you add "After picking up the line,Displays the current linear scale value in Command Bar" ? so when I change ,I have a Reference value

Link to comment
Share on other sites

Thank you ! Tharwat ,You answered my question correctly!If can automatically adjust will be better

 

You're welcome .

 

Can you add "After picking up the line,Displays the current linear scale value in Command Bar" ? so when I change ,I have a Reference value

 

This ... ?

 

(defun c:Test (/ ss l n e)
 ;;    Tharwat 02.01.2014    ;;
 (if (and (setq ss (ssget "_:L" '((0 . "*LINE")))) (setq l (getdist "\n Specify Line Type Scale :")))
   (repeat (setq n (sslength ss))
     (setq e (entget (ssname ss (setq n (1- n)))))
     (entmod (append e (list (cons 48 l))))
   )
 )
 (if l (princ (strcat "\n Ltype value: " (rtos l 2))))
 (princ)
)

 

Did you receive my Private Message ?

Link to comment
Share on other sites

You're welcome .

 

 

 

This ... ?

 

(defun c:Test (/ ss l n e)
 ;;    Tharwat 02.01.2014    ;;
 (if (and (setq ss (ssget "_:L" '((0 . "*LINE")))) (setq l (getdist "\n Specify Line Type Scale :")))
   (repeat (setq n (sslength ss))
     (setq e (entget (ssname ss (setq n (1- n)))))
     (entmod (append e (list (cons 48 l))))
   )
 )
 (if l (princ (strcat "\n Ltype value: " (rtos l 2))))
 (princ)
)

 

Did you receive my Private Message ?

 

Hi!Tharwat , It is not,Command bar shows the modified values ,I mean: apload test.lisp ,run"test" ,Pick up the line ,Spaces or Enter, command bar display:The current linear scale is:**,Specify Line Type Scale :

Link to comment
Share on other sites

This ... ?

(defun c:Test (/ ss n e)
 ;;    Tharwat 02.01.2014    ;;
 (if
   (and (progn
          (princ
            "\n Select any kind of lines to change the LType scale ..."
          )
          (setq ss (ssget "_:L" '((0 . "*LINE"))))
        )
        (princ (strcat "\n Current Ltype scale of last objects < "
                       (if *ltsv*
                         (rtos *ltsv* 2)
                         "0.0"
                       )
                       " > "
               )
        )
        (setq *ltsv* (getdist "\n Specify Line Type Scale :"))
   )
    (repeat (setq n (sslength ss))
      (setq e (entget (ssname ss (setq n (1- n)))))
      (entmod (append e (list (cons 48 *ltsv*))))
    )
 )
 (princ)
)
(princ)
(princ "\n** Type < Test > to invoke the command **")
(princ)

Link to comment
Share on other sites

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