Jump to content

Change to get result of text to Excel Workbook cell. Pls Help


Recommended Posts

Hai, i need a help.

I have a working lisp routine which gives me distance(chainage) of polyline 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"))
    (and (setq s (car (entsel "\nPick a polyline :")))
	 (or (= (cdr (assoc 0 (entget s))) "LWPOLYLINE")
	     (alert "Invalid object! Please pick a polyline only.")
	   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)



Link to comment
Share on other sites

I've been working on something similar, and while I haven't nailed it down myself, I can say it is indeed possible.


Perhaps this thread might help you out?: 


  • Like 1
Link to comment
Share on other sites

I think the key to the next step is recording your text as you go, I would save that as list, 



(setq MyList (list))


somewhere near the beginning to make a blank list, then this bit to populate it all


(setq MyList (append MyList (strcat "FF-LINE 01" ) (strcat "CH=" (itoa (+ (atoi sch) f)) "+" (rtos di 2 3)) ))


I don't use spreadsheets a lot but once you have the text as a variable you can pass that to the next step to populate the spreadsheet.


if you want it a bit more manual than I would make a list with all the points, then write it to a deliminated text file, import that to excel after you have done the CAD stuff.


if you can get a LISP to update spreadsheet as you go then each loop set MyList as an empty list, write then text to it and then send to the spreadsheet



For now while you are waiting on an answer to the spreadsheet part, add in the text to a variable or list and it will be easier after that



  • Agree 2
Link to comment
Share on other sites

Sorry but i don't know any basics of this coding. trying to learn but its so hard for me. i am a draftsman and so many lisp from here helped me a lot. 


Please let me know of this is possible in any ways. thanks.


Ive attached a sample of the existing lisp working and needed results in excel. Please check. thanks.


Link to comment
Share on other sites

If you just want the chainages then the simplest way is just make a csv file and open in excel.


Here in Aus we just use the CH 60190.345 much easier the + adds a complication as well as the Mtext which needs to be removed.


Need some time maybe some one else will jump in.



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.

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