What is a good way to create mleaders from a *.csv file?

What is a good way to create mleaders from a *.csv file?

Anonymous
Not applicable
1,587 Views
5 Replies
Message 1 of 6

What is a good way to create mleaders from a *.csv file?

Anonymous
Not applicable

I want to open this csv file, and have it draw a multileader at each x,y coordinate using each additional comma separated value as a new line in the multileader.

 

Can someone point me in the right direction? 

 

I attached a file of my example.  Number of lines in the text file could be arbitrarily long.

 

Thank you,

0 Likes
Accepted solutions (1)
1,588 Views
5 Replies
Replies (5)
Message 2 of 6

hmsilva
Mentor
Mentor

@Anonymous wrote:

... and have it draw a multileader at each x,y coordinate ...


Hi smay8399,

you only have one point per text line, is your mleaderstyle defined without leader, only text?

Or are you going to calculate the second point from the that point?

 

Henrique

EESignature

0 Likes
Message 3 of 6

Anonymous
Not applicable
I want to calculate the leader and the landing from the first point. The X,Y point is the center of a manhole or other items of interest on the drawing. I have an excel sheet that I'm exporting the *.csv from
0 Likes
Message 4 of 6

hmsilva
Mentor
Mentor
Accepted solution

Untested...

 

(defun c:demo (/ *error* parse file fname line lst pt str x y)
   
   (defun *error* (msg)
      (if file
         (close file)
      )
      (cond ((not msg))
            ((member msg '("Function cancelled" "quit / exit abort")))
            ((princ (strcat "\n** Error: " msg " ** ")))
      )
      (princ)
   )

   (defun parse (str del / lst pos)
      (while (setq pos (vl-string-search del str))
         (setq lst (cons (substr str 1 pos) lst)
               str (substr str (+ pos 2))
         )
      )
      (reverse lst)
   )

   (if (and (setq fname (getfiled "" "" "csv" 8))
            (setq file (open fname "r"))
       )
      (progn
         (read-line file) ; to remove the header
         (while (setq line (read-line file))
            (setq lst (parse line ",")
                  x   (atoi (car lst))
                  lst (cdr lst)
                  y   (atoi (car lst))
                  lst (cdr lst)
                  pt  (list x y)
                  str (vl-string-right-trim
                         "\\P"
                         (apply 'strcat (mapcar (function (lambda (x) (strcat x "\\P"))) lst))
                      )
            )
            (command "mleader" pt (polar pt (* pi 0.25) 50.0) str); change the polar point...
         )
      )
   )
   (*error* nil)
   (princ)
)

 

Hope this helps,
Henrique

EESignature

0 Likes
Message 5 of 6

Anonymous
Not applicable

Thanks, that helps a lot.  I will post my final lisp file when it is done. 

0 Likes
Message 6 of 6

hmsilva
Mentor
Mentor

@Anonymous wrote:

Thanks, that helps a lot.  I will post my final lisp file when it is done. 


You're welcome!
Glad I could help

Henrique

EESignature

0 Likes