| Author |
Message |
giovanni64
Joined: 08 Mar 2006
Posts: 3
|
Posted:
Wed Mar 08, 2006 5:08 pm Post subject:
Polyline routine for changing the width |
|
|
I would appreciate it if someone could help me with the following routine.
I can't get it work with AutoCAD 2004 and always receive a "unknown command polchg.
;***************************************************
; This Program changes Lines in Polylines
; and changes the width.
;***************************************************
(defun C:POLCHG ()
(defun ac (v) (assoc v pasa))
(defun ers (a b c)(setq pasa (subst (cons a b) c pasa)))
(setq aws (ssget))
(setq wasa (sslength aws))
(setq brn (getreal
"\nPolyline/Polyline-Width, Return, if no change: "))
(if (= brn nil)(prompt "\n*No Change*")
(progn
(setq index 0)
(while (< index wasa) ;or [repeat
(command "pedit" aws "" "")
(setq index (1+ index))
(setq pasa (entget (entlast)))
(setq br1 (ac 40) br2 (ac 41))
(ers 40 brn br1)(ers 41 brn br2)
(entmod pasa)))) ;end while, progn, if
(grtext)(princ)
) ;EOF POLCHG.LSP
|
|
| Back to top |
|
 |
CarlB
Joined: 27 Sep 2005
Posts: 52
|
Posted:
Wed Mar 08, 2006 11:25 pm Post subject:
|
|
|
What do you want the routine to do? I see a few problems with it:
(command "pedit" aws "" "")
This line does nothing - pedit, pass it a selection, 2 returns - nothing.
"index" is not used in the code other than control number loops, but in each loop the same operation is performed, acting on 'pasa' which is the last entity (entlast) which might not be the selected entity.
Let us know a little more what you're trying to do and I can give some suggestions. |
|
| Back to top |
|
 |
giovanni64
Joined: 08 Mar 2006
Posts: 3
|
Posted:
Thu Mar 09, 2006 8:40 am Post subject:
|
|
|
Thanks for the reply.
I want the routine that it converts one or multiple lines into polylines and changes the width as well. The more I tried to get it fixed the more I'm stepping in a jungle.
It's a long time ago since I worked with Lisp.
|
|
| Back to top |
|
 |
CarlB
Joined: 27 Sep 2005
Posts: 52
|
Posted:
Thu Mar 09, 2006 5:59 pm Post subject:
|
|
|
Quick shot at it, needs your testing/error checking, etc:
(defun C:POLCHG ()
(setvar "peditaccept" 1)
(setq brn (getreal
"\nPolyline/Polyline-Width, Return, if no change: "))
(setq aws (ssget))
(command "_.pedit" "_m" aws "" "_w" brn "")
(princ)
) |
|
| Back to top |
|
 |
giovanni64
Joined: 08 Mar 2006
Posts: 3
|
Posted:
Thu Mar 09, 2006 8:21 pm Post subject:
|
|
|
Thanks a lot CarlB for your great help.
I tested it and it runs without any problems. Compared to the other with less lines. Incredible!
 |
|
| Back to top |
|
 |
CarlB
Joined: 27 Sep 2005
Posts: 52
|
Posted:
Thu Mar 09, 2006 10:15 pm Post subject:
|
|
|
You're welcome.
I like to keep them as short as possible. In that spirit, this gets it done also:
(defun C:POLCHG ()
(setvar "peditaccept" 1)
(command "pedit" "m" (ssget) "" "w" pause "")
) |
|
| Back to top |
|
 |
|
|
|
|