Polyline routine for changing the width
CADForums.net Forum Index CADForums.net
Discussion of AutoCAD and other CAD software.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web cadforums.net
Polyline routine for changing the width

 
Post new topic   Reply to topic    CADForums.net Forum Index -> Customization
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 Reply with quote

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

Crying or Very sad

Back to top
View user's profile Send private message
CarlB



Joined: 27 Sep 2005
Posts: 52

Posted: Wed Mar 08, 2006 11:25 pm    Post subject: Reply with quote

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
View user's profile Send private message
giovanni64



Joined: 08 Mar 2006
Posts: 3

Posted: Thu Mar 09, 2006 8:40 am    Post subject: Reply with quote

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.

Crying or Very sad

Back to top
View user's profile Send private message
CarlB



Joined: 27 Sep 2005
Posts: 52

Posted: Thu Mar 09, 2006 5:59 pm    Post subject: Reply with quote

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
View user's profile Send private message
giovanni64



Joined: 08 Mar 2006
Posts: 3

Posted: Thu Mar 09, 2006 8:21 pm    Post subject: Reply with quote

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!

Very Happy
Back to top
View user's profile Send private message
CarlB



Joined: 27 Sep 2005
Posts: 52

Posted: Thu Mar 09, 2006 10:15 pm    Post subject: Reply with quote

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
View user's profile Send private message
 
Post new topic   Reply to topic    CADForums.net Forum Index -> Customization All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Windows Server DSP VoIP Electronics New Topics
Powered by phpBB