minejash Posted July 19, 2022 Posted July 19, 2022 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")) (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) LINE CHAIN & CORDS - CAA.LSP Quote
Kreaten_vhar Posted July 19, 2022 Posted July 19, 2022 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?: 1 Quote
Steven P Posted July 19, 2022 Posted July 19, 2022 I think the key to the next step is recording your text as you go, I would save that as list, put (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 2 Quote
BIGAL Posted July 20, 2022 Posted July 20, 2022 Have a look at this and in particular putcell function, you need to understand about working with Acad <-> excel. Alan Excel library.lsp 2 Quote
minejash Posted July 20, 2022 Author Posted July 20, 2022 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. FF INTER CHAIN.dwg FF INTER CHAIN.xlsx Quote
Abhi4u Posted July 20, 2022 Posted July 20, 2022 Any help on this one please. Could help me a lot. Quote
BIGAL Posted July 21, 2022 Posted July 21, 2022 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. Quote
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.