Anushka Posted February 13, 2020 Share Posted February 13, 2020 (edited) why the code doesn't work ?? I'm trying to develop a snippet report, I need to export to a .csv the color of the polyline and the block it is passing, Example: RED or 1; 01; 02; 65 I'm trying this way and I don't know why it doesn't work, can someone help me ??? example of .dwg, I thank you already !!! (defun c:SS () (setq ss (ssget '((0 . "LWPOLYLINE")))) (setq file (open (strcat (getvar 'dwgprefix) (vl-filename-base (getvar 'dwgname)) ".csv") "w")) (write-line "color;Start") (repeat (setq i (sslength ss)) (setq plineobj (vlax-ename->vla-object (setq entname (ssname ss (setq i (1- i)))))) (setq entdata (entget (ssname ss 0))) (setq ll (vl-remove-if 'not (mapcar (function (lambda ( p ) (if (= 10 (car p))(:Addzerolist 0.00 2 (cdr p))))) entdata))) (foreach ponto ll (progn (if (and (setq selptsvert (ssget "_C" (mapcar '+ ponto '(5 5)) (mapcar '- ponto '(5 5)) '((0 . "INSERT") (2 . "`*U*")))) (= (sslength selptsvert) 1) ) (progn (setq blkt (vlax-ename->vla-object (ssname selptsvert 0))) (setq tt (LM:vl-getattributevalue blkt "NUMBER")) ) ;;(exit) ) (write-line tt file) (close file) ) ) ) ) Edited February 14, 2020 by Anushka Quote Link to comment Share on other sites More sharing options...
BIGAL Posted February 14, 2020 Share Posted February 14, 2020 Made a couple of changes the 1st was defun name it did not like ss. Got to lee's get attributes I normally code that in its only about 4 lines. So did not test further. (defun c:SSzz () (setq ss (ssget '((0 . "LWPOLYLINE")))) (setq file (open (strcat (getvar 'dwgprefix) (vl-filename-base (getvar 'dwgname)) ".csv") "w")) (write-line "color;Start") (repeat (setq i (sslength ss)) (setq entdata (entget (ssname ss (setq i (- i 1))))) (setq ll (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) entdata))) (foreach ponto ll (progn (if (and (setq selptsvert (ssget "_C" (mapcar '+ ponto '(5 5)) (mapcar '- ponto '(5 5)) '((0 . "INSERT") (2 . "`*U*")))) (= (sslength selptsvert) 1) ) (progn (setq blkt (vlax-ename->vla-object (ssname selptsvert 0))) (setq tt (LM:vl-getattributevalue blkt "NUMBER")) ) ) (write-line tt file) (close file) ) ) ) ) (foreach att (vlax-invoke (vlax-ename->vla-object (ssname selptsvert 0 )) 'getattributes) (if (= (vla-get-tagstring att) "NUMBER") (setq tt (vla-get-textstring att )) ) ) 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.