Jump to content

Excerpts in .csv


Anushka

Recommended Posts

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 by Anushka
Link to comment
Share on other sites

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 ))
        )
)

 

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...