TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: MeasureUp on December 22, 2010, 06:32:28 PM

Title: Change LineType Scale...
Post by: MeasureUp on December 22, 2010, 06:32:28 PM
There is no problems when changing linetype scale by selecting object on the screen.
Quote
command: chprop -> select object -> "s"
But this won't work when writing to the code.
For example, I want to change the selected object to
1) Layer: steel
2) Linetype Scale: 0.5
And the following is what I get.
Code: [Select]
(command "._chprop" "last" "" "layer" "Steel" "" "S" "0.5")
Quote
Command: ._chprop
Select objects: last 1 found

Select objects:
Enter property to change
[Color/LAyer/LType/ltScale/LWeight/Thickness/TRansparency/Material/Annotative]:
layer
Enter new layer name <Dims>: Steel
Enter property to change
[Color/LAyer/LType/ltScale/LWeight/Thickness/TRansparency/Material/Annotative]:
Command: S Unknown command "S".  Press F1 for help.

Command: 0.5 Unknown command "5".  Press F1 for help.

Does anyone has a solution?
Thanks for your help.
Title: Re: Change LineType Scale...
Post by: Jeff_M on December 22, 2010, 06:39:46 PM
Move the quotes between "Steel" and "S" to the end:

(command "._chprop" "last" "" "layer" "Steel" "S" "0.5" "")
Title: Re: Change LineType Scale...
Post by: MeasureUp on December 22, 2010, 07:10:49 PM
Move the quotes between "Steel" and "S" to the end:

(command "._chprop" "last" "" "layer" "Steel" "S" "0.5" "")
That is it.
Thank you very much & merry Christmas.
Title: Re: Change LineType Scale...
Post by: Lee Mac on December 23, 2010, 05:46:54 AM
Should you want to approach it another way  :-)

Code: [Select]
(defun c:test ( / ss i )

  (if (setq ss (ssget "_L"))
    (repeat (setq i (sslength ss))
      (entupd
        (cdr
          (assoc -1
            (_UpdateDXF  48 0.5
              (_UpdateDXF 8 "Steel"
                (entget (ssname ss (setq i (1- i))))
              )
            )
          )
        )
      )
    )
  )

  (princ)
)

(defun _UpdateDXF ( code value elist )
  (cond ( (entmod (list (assoc -1 elist) (cons code value))) ) ( elist ))
)

Merry Christmas guys!  :-)
Title: Re: Change LineType Scale...
Post by: alanjt on December 23, 2010, 08:51:10 AM
Do you find inconsistencies in using entmod that way? I tried it a few weeks back, but it didn't work on LWPolylines and randomly didn't work on Lines.

Also, you shouldn't need to step through the selection set since (ssget "_L") will only select the last object - (ssname ss 0) should suffice, or am I just wrong?
Title: Re: Change LineType Scale...
Post by: Lee Mac on December 23, 2010, 09:34:21 AM
Do you find inconsistencies in using entmod that way? I tried it a few weeks back, but it didn't work on LWPolylines and randomly didn't work on Lines.

I've found it works in most cases, but not when updating MText formatting, or on non-graphical entities such as layers etc.

Also, you shouldn't need to step through the selection set since (ssget "_L") will only select the last object - (ssname ss 0) should suffice, or am I just wrong?

Good point, I think does only collect one entity - oh well, at least its open for easy modification should the user want to change it  :-)
Title: Re: Change LineType Scale...
Post by: alanjt on December 23, 2010, 10:15:43 AM
Do you find inconsistencies in using entmod that way? I tried it a few weeks back, but it didn't work on LWPolylines and randomly didn't work on Lines.

I've found it works in most cases, but not when updating MText formatting, or on non-graphical entities such as layers etc.
Well, not working on LWPolylines and sometimes on Lines is enough for me to not use it. I was curious if it was only me or you had similar results.