Help to get result of text to Excel cell

Help to get result of text to Excel cell

mint09
Enthusiast Enthusiast
826 Views
7 Replies
Message 1 of 8

Help to get result of text to Excel cell

mint09
Enthusiast
Enthusiast

Hai, i need a help in a lisp code. I have a working lisp routine which gives me distance(chainage) of pline when clicked on the pline i selected. It will add a text there showing chainage.

Only thing i want is i need the chainage also in an external Excel Workbook cell. Like when i click and get the chainage there i want to get that chainage in excel workbook cell which is open (like Click to Xls lisp).

 

Pls reply if its possible... thanks🙂

 

Attaching the lisp file and also adding same lisp code below.

;-- PIPE CHAINAGE abhi- CAA --
(defun c:CAA (/ s p c tp sch f)
(setvar "cmdecho" 0)
 (setq sch (getstring "\nSpecify start chainage : <0>"))			;"0" is set as the default value
  (if (= sch "")(setq sch "0"))
  (if
    (and (setq s (car (entsel "\nPick a polyline :")))
	 (or (= (cdr (assoc 0 (entget s))) "LWPOLYLINE")
	     (alert "Invalid object! Please pick a polyline only.")
	 )
    )
     (while
       (and
	 (setq
	   p (getpoint "\nSpecify point :")
	 )
	 (setq c (vlax-curve-getclosestpointto s p))
	 	 (setq tp (getpoint "\nSpecify Point for Text : "))
       )
	  (setq di (vlax-curve-getdistatpoint s c))
	  (setq f (fix (/ di 1000.0)))
	  (setq di (- di (*  f 1000.0)))
		(command "_.LEADER" c tp "" 
				(strcat "FF-LINE 01" )
				(strcat "CH=" (itoa (+ (atoi sch) f)) "+" (rtos di 2 3))
				""
		)
		(vlax-put-property (vlax-ename->vla-object (entlast)) 'height 3.50);;; Text Height 3.50
     )
  )
  (setvar "cmdecho" 1)
  (princ)
)
(vl-load-com)

 

0 Likes
Accepted solutions (1)
827 Views
7 Replies
Replies (7)
Message 2 of 8

mint09
Enthusiast
Enthusiast

Any help with get List or anything is appreciated. 

0 Likes
Message 3 of 8

devitg
Advisor
Advisor

@mint09 Please upload your dwg an xls samples. 

It will be easy to save to a CSV file , than to a cell at XLS 

 

0 Likes
Message 4 of 8

devitg
Advisor
Advisor

@mint09  test the  attached lsp

 

Message 5 of 8

mint09
Enthusiast
Enthusiast

thanks for the replay, But this is not working. It opens a text file but then the lisp routine ends. 

Ive attached CAD & excel file as what i am trying to do. Please check,

@devitg 

Thank you..

0 Likes
Message 6 of 8

mint09
Enthusiast
Enthusiast

Anyone please helps on the code. It'll be a huge headache gone. Thanks

0 Likes
Message 7 of 8

Sea-Haven
Mentor
Mentor
Accepted solution

Try this

Message 8 of 8

mint09
Enthusiast
Enthusiast

Thank you so much. This works like i wanted.

 

Thank you @Sea-Haven ..

0 Likes