Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

linesum lisp - 1 attachment

20 REPLIES 20
Reply
Message 1 of 21
Anonymous
1235 Views, 20 Replies

linesum lisp - 1 attachment

I have a lisp that gives me the total length of lines on a certain layer, it goes LWpolylines, lines and arcs. I need to have the old style polylines added to this routine. Can someone help me out here? I think I found where it needs to be added, but I'm not a LISP programmer... 😞
20 REPLIES 20
Message 2 of 21
EC-CAD
in reply to: Anonymous

(cond
((= e_type "LINE") (ad_lines001))
((= e_type "PLINE") (ad_lines001)); Add this..

Bob
Message 3 of 21
Anonymous
in reply to: Anonymous

ECCAD typed the following message: > (cond > ((= e_type "LINE") (ad_lines001)) > ((= e_type "PLINE") (ad_lines001) Keeps saying Initializing... (cond ((= e_type "LINE") (ad_lines001)) ((= e_type "PLINE") (ad_lines001)) ((= e_type "ARC") (ad_arcs001)) ((= e_type "LWPOLYLINE") (ad_poly001)) ((or (/= e_type "LINE") (/= e_type "PLINE") (/= e_type "ARC") (/= e_type "LWPOLYLINE") ) (ssdel en selset));or
Message 4 of 21
Anonymous
in reply to: Anonymous

You also need to change the line (setq en (ssname selset 0)) to (setq en (ssname selset c)) Here is an alternative and you don't need the added functions ... (defun c:lines () (setq llst (list (tblnext "LAYER" T))) (while (setq lay (tblnext "LAYER")) (if (/= lay "") (setq llst (cons lay llst)) ) ) (setq n 0) (initget "All Select A S") (setq NUMLAY (getkword (strcat "\nDo you want all layers or select one.. ( or Select) "))) (if (or (= NUMLAY "Select")(= NUMLAY "S")) (progn (setq LAYER (setq a (cdr (assoc 8 (entget (car (entsel))))))) (setq LLST (tblsearch "LAYER" LAYER)) (setq REP 1) ) (setq REP (length llst)) ) (initget "Y N") (setq DIA (getkword (strcat "\nDo you want a dialog box..(Y or ) "))) (repeat REP (if (= REP 1) (setq name (cdr (assoc 2 llst))) (setq name (cdr (assoc 2 (nth n llst)))) ) (setq selset(ssget "X" (list (cons 0 "LINE,ARC,LWPOLYLINE,POLYLINE")(cons 8 name)))) (setq tot_len 0) (if selset (progn (setq c 0) (repeat (sslength selset) (setq en (ssname selset c) ed (entget en) e (vlax-ename->vla-object en) line_len (vlax-curve-getdistAtParam e (vlax-curve-getEndParam e)) tot_len (+ tot_len line_len) ) (setq c (1+ c)) ) ) ) (setq n (+ 1 n)) (cond ((> (strlen name) 27) (setq name (strcat name "\t")) ) ((> (strlen name) 20) (setq name (strcat name "\t\t")) ) ((> (strlen name) 13) (setq name (strcat name "\t\t\t")) ) ((> (strlen name) 6) (setq name (strcat name "\t\t\t\t")) ) ((> (strlen name) 0) (setq name (strcat name "\t\t\t\t\t")) ) ) (prompt (strcat "layer: " name "Total length is: " (rtos tot_len 2 2)))(terpri) (if (= DIA "Y") (alert (strcat "layer: " name "Total length is: " (rtos tot_len 2 2))) ) );repeat (princ) ) "Keith" wrote in message news:409f937b$1_3@newsprd01... > ECCAD typed the following message: > > > (cond > > ((= e_type "LINE") (ad_lines001)) > > ((= e_type "PLINE") (ad_lines001) > > Keeps saying Initializing... > > (cond > ((= e_type "LINE") (ad_lines001)) > ((= e_type "PLINE") (ad_lines001)) > ((= e_type "ARC") (ad_arcs001)) > ((= e_type "LWPOLYLINE") (ad_poly001)) > ((or > (/= e_type "LINE") > (/= e_type "PLINE") > (/= e_type "ARC") > (/= e_type "LWPOLYLINE") > ) > (ssdel en selset));or
Message 5 of 21
urugx
in reply to: Anonymous

Try "POLYLINE" instead of "PLINE"!!!!!
Message 6 of 21
Anonymous
in reply to: Anonymous

Jim Claypool typed the following message: > You also need to change the line > (setq en (ssname selset 0)) > to > (setq en (ssname selset c)) > > Here is an alternative and you don't need the added functions ... > (defun c:lines () > (setq llst (list (tblnext "LAYER" T))) > (while (setq lay (tblnext "LAYER")) > (if (/= lay "") Look at the attached DWG, I used your alterante code and still didn't get the correct lengths.
Message 7 of 21
bob.at
in reply to: Anonymous

Keith,

Assuming that the code is working for lines, arcs and lwpolylines correct, you should change the if statment as follows (lines 51 - 71):


(if selset
(progn
(repeat (sslength selset)
(setq en (ssname selset 0))
(setq ed (entget en))
(setq e_type (cdr (assoc '0 ed)))
(cond
((= e_type "LINE") (ad_lines001))
((= e_type "ARC") (ad_arcs001))
((= e_type "LWPOLYLINE") (ad_poly001))
((= e_type "POLYLINE") (ad_poly001))
);cond
(ssdel en selset)
)
)
)

bob.at

For all how want not only know the "how" but also the "why":
You cant use ad_lines001 for polylines, because it has no vertices at group code 10 and 11.
You did not nead the or statement in the cond; becaus this is an or wich is *always* true!
You do not need var c becaus with ssdel the actual entity is removed from selset and so you can always point to the first element in selset.


Message was edited by: bob.at
Message 8 of 21
Anonymous
in reply to: Anonymous

bob.at typed the following message: > (if selset > (progn > (repeat (sslength selset) > (setq en (ssname selset 0)) > (setq ed (entget en)) > (setq e_type (cdr (assoc '0 ed))) > (cond > ((= e_type "LINE") (ad_lines001)) > ((= e_type "ARC") (ad_arcs001)) > ((= e_type "LWPOLYLINE") (ad_poly001)) > ((= e_type "POLYLINE") (ad_poly001)) > );cond > (ssdel en selset) > ) > ) > ) still getting the continuting Initializing...
Message 9 of 21
Anonymous
in reply to: Anonymous

Keith Maybe you find something usefull in this program: (defun C:VxGetAllLength ( / CurObj CurSet FltLst TmpLgt TotLgt) (if (< (atof (getvar "ACADVER")) 15.0) (alert " VxGetAllLength requires AutoCAD 2000 or higher. ") (progn (vl-load-com) (setq FltLst '((0. "3DPOLY,ARC,CIRCLE,ELLIPSE,LINE,LWPOLYLINE,POLYLINE,SPLINE") (-4 . "") (-4 . "NOT>") ) CurSet (cond ((ssget "I" FltLst)) ((ssget FltLst))) TotLgt 0 ) (if CurSet (progn (while (setq CurEnt (ssname CurSet 0)) (setq CurObj (vlax-ename->vla-object CurEnt) TmpLgt (vlax-curve-getDistAtParam CurObj (vlax-curve-getEndParam CurObj) ) TotLgt (+ TotLgt TmpLgt) CurSet (ssdel CurEnt CurSet) ) ) (alert (strcat "Total length of selected object(s) " (rtos TotLgt) ".")) ) ) ) ) (princ) ) Cheers -- Juerg Menzi MENZI ENGINEERING GmbH, Switzerland http://www.menziengineering.ch
Message 10 of 21
Anonymous
in reply to: Anonymous

error: bad SSGET list
Message 11 of 21
bob.at
in reply to: Anonymous

Keith,

i cant see your problem. With my changes you get the following in aour sample dwg:
layer: c-ss-gravity-service Total length is: 4405.27
layer: c-ss-gravity Total length is: 11371.20
(instead of 6647.40 with the old version)

And i have checked this manually, it is correct.

bob.at
Message 12 of 21
Anonymous
in reply to: Anonymous

Keith Line wrapping... (setq FltLst '((0 . "3DPOLY,ARC,CIRCLE,ELLIPSE,LINE,LWPOLYLINE,POLYLINE,SPLINE") ... Cheers -- Juerg Menzi MENZI ENGINEERING GmbH, Switzerland http://www.menziengineering.ch
Message 13 of 21
Anonymous
in reply to: Anonymous

Keith To avoid further troubles the file as attachment... Cheers -- Juerg Menzi MENZI ENGINEERING GmbH, Switzerland http://www.menziengineering.ch Attachment not added (content type not allowed): "VxGetAllLength.lsp"
Message 14 of 21
Anonymous
in reply to: Anonymous

bob.at typed the following message: > Keith, > > i cant see your problem. With my changes you get the following in aour > sample dwg: layer: c-ss-gravity-service Total length is: > 4405.27 layer: c-ss-gravity Total length > is: 11371.20 (instead of 6647.40 with the old version) > > And i have checked this manually, it is correct. > > bob.at Can you post the LSP you used?? I'm getting an error in the file yet.
Message 15 of 21
Anonymous
in reply to: Anonymous

 
Message 16 of 21
Anonymous
in reply to: Anonymous

Keith schrieb: I told you: 'Maybe you find something usefull in this program...' But to solve your problem check the attachment. Cheers -- Juerg Menzi MENZI ENGINEERING GmbH, Switzerland http://www.menziengineering.ch Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp" Attachment not added (content type not allowed): "VxGetAllLength.lsp"
Message 17 of 21
bob.at
in reply to: Anonymous

voila
If its still not working: AutoCAD version, which error message?

bob.at
Message was edited by: bob.at
Message 18 of 21
Anonymous
in reply to: Anonymous

Hi Jürg, I like YOUR local variables names, have you a list of them? Cheers. Marco -- EntNam EntDat CrlDat TxtDat InsDat GrpDat EntClr EntDtX LowLft UppRgt LinSrt LinEnd CrcRad SsOrg SsXdat SelSet NumObj SsLngt SSIndx Dxf__0 DxfSrt DxfEnd Deg090 AddRem AppNam ApsLst ApsStr PtsLst TmpLst FlsLst FilNam ImpFil FilPtr OldNam NewNam VlaObj TrueFl FlgSlt Countr BitFlg BitRif debug DclId TilNam DclAct WhtNxt DimLFt AcdVer SttLst PrmLst EnsLst PtnRif AngRif DstRif MisVal AltStr ValStr TotStr TxtHgt TxtAng TxtSty StrLng ReaNum ForElm VLA Acad globals: *AcadApp* = Acad.Application - *ActiveDwg* = ActiveDocument VLA Excel globals: *ExcelApp* = Excel.Application - *ActiveWbk* = ActiveWorkbook *ActiveSht* = ActiveSheet - *ActiveCls* = ActiveCells -- ________________________________________________ Marc'Antonio Alessi http://xoomer.virgilio.it/alessi (strcat "NOT a " (substr (ver) 8 4) " guru.") ________________________________________________
Message 19 of 21
Anonymous
in reply to: Anonymous

I used your drawing and my code. In the drawing c-ss-gravity-service AutoCAD reports 4405.28 My program reports 4405.27 c-ss-gravity AutoCAD reports 11371.21 My program reports 11371.19 That would be close enough for me. "Keith" wrote in message news:409f9f70_3@newsprd01... > Jim Claypool typed the following message: > > > You also need to change the line > > (setq en (ssname selset 0)) > > to > > (setq en (ssname selset c)) > > > > Here is an alternative and you don't need the added functions ... > > (defun c:lines () > > (setq llst (list (tblnext "LAYER" T))) > > (while (setq lay (tblnext "LAYER")) > > (if (/= lay "") > > > Look at the attached DWG, I used your alterante code and still didn't get > the correct lengths. > >
Message 20 of 21
Anonymous
in reply to: Anonymous

Marc'Antonio > ... have you a list of them? Unfortunately not, but it's easy to create this 'talking' var names... Cheers -- Juerg Menzi MENZI ENGINEERING GmbH, Switzerland http://www.menziengineering.ch

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost