Trebuchet Posted October 9, 2008 Share Posted October 9, 2008 Hello everyone! I've been searching for days off and on trying to find a solution to a problem I have. I have seen several people ask a question very similar to this, but have found no answers. I have hundreds of polylines in my drawings, which represent steel reinforcement... I would like to use data extraction to take the lengths of these polylines, do some simple arithmetic to them and export this information into a table, or excel spreadsheet so that I can show the cut length, elongation, etc... The problem I'm having is that I have no way to identify which polylines are which. I need a way to name a polyline (i.e Tendon_1, Tendon_2, etc.. ) so that the length of the polylines are useful to me. The lengths are generally many different values. Looking at the data extraction set for a polyline, there are several categories which I could use, such as comments, subject, title... although I don't know how to assign this attribute to a specific polyline. So I'm guessing I need a lisp routine to tag polylines with a marker of some kind??? Anyone have any ideas? Thank you so much. Quote Link to comment Share on other sites More sharing options...
fixo Posted October 10, 2008 Share Posted October 10, 2008 Try the following 2 lisps I made up Feel free to change both to your suit ;; AXD.lsp ;; set xdata (vl-load-com) (defun C:AXD (/ acapp adoc appname counter obj ss xtype xvalue) (setq acapp (vlax-get-acad-object) adoc (vla-get-activedocument acapp) ) ;; define application name (setq appname "STEEL_ENFORCE") ;; register application, if this registered earlier, ;; just ignore it (vl-catch-all-apply (function (lambda() (regapp appname))) (alert (strcat "Select steel enforcement,\n then enter data for them,\n then repeat the same for next one")) ;; (setq counter 1) (while ; loop (setq ss (ssget "_+.:S:E" (list (cons 0 "*POLYLINE");|(cons 8 "M-STEEL-DETAIL")|));<==change layer name if you need it (progn (setq obj (vlax-ename->vla-object (ssname ss 0)) xtype (list 1001;|appname|; 1000;|Tendon#|; 1041;|length|; 1041;|elongation|; 1040;|diameter|; 1000;|subject|; 1000;|comments|; 1000;|title|; ) ) (setq xvalue (list appname (strcat "Tendon_" (itoa counter)) (vlax-curve-getdistatparam obj (vlax-curve-getendparam obj)) (getreal (strcat "\nEnter elongation for Tendon#" (itoa counter) ": ")) (getreal "\nEnter diameter: ") (getstring T "\nEnter subject description (less than 256 characters!): ") (getstring T "\nEnter comments (less than 256 characters!) : ") (getstring T "\nEnter title : ") ) ) (vlax-invoke obj 'SetXdata xType xvalue ) (setq counter (1+ counter)) (setq xvalue nil) ) ) ) (princ) ) (princ "\nType AXD to add xdata") (princ) ;; XDT.lsp ;; read xdata and write it in .CSV file (comma separated) (vl-load-com) (defun C:XDT (/ appname data en fdesc fn obj ss xdv) (setq appname "STEEL_ENFORCE") (setq fn (strcat (getvar "dwgprefix") (vl-filename-base (getvar "dwgname")) ".csv")) (if (not (findfile fn)) (setq fdesc (open fn "w")) (setq fdesc (open fn "a")) ) (setvar "cmdecho" 0) (write-line "Name,Length,Elongation,Diameter,Subject,Description,Comments,Title" fdesc) (setq ss (ssget "_X" (list (list -3 (list appname))))) (while (setq en (ssname ss 0)) (setq obj (vlax-ename->vla-object (ssname ss 0))) (vla-getXdata obj appname 'xtp 'xdv ) (setq data (cdr (mapcar 'vlax-variant-value (vlax-safearray->list xdv) ) ) ) (ssdel en ss) (write-line (strcat (car data) "," (rtos (cadr data) 2 2) "," (rtos (caddr data) 2 2) "," (rtos (cadddr data) 2 2) "," (nth 4 data) "," (nth 5 data) "," (nth 6 data)) fdesc) ) (close fdesc) (setvar "cmdecho" 1) (princ) ) (princ "\nType XDT to write xdata to file") (princ) ~'J'~ Quote Link to comment Share on other sites More sharing options...
Trebuchet Posted October 14, 2008 Author Share Posted October 14, 2008 Thank you very much fixo. I have never used Xdata before, and it will be a good thing for me to learn. Thank you again. Quote Link to comment Share on other sites More sharing options...
fixo Posted October 14, 2008 Share Posted October 14, 2008 You're welcome Happy computing ~'J'~ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.