noyjoreb Posted April 9, 2010 Posted April 9, 2010 hi gud day, i also search a lisp here about getting the coordinates of point that will be pick... i have a suggestion if its possible that once u select a point1 and point 2 it will automatical create a table with lables such as line #, x coordinate, y coordinate and a distance? hope anybody can answer... tnx a lot and more power.... Quote
Lee Mac Posted April 9, 2010 Posted April 9, 2010 Try this: (defun c:LabTab (/ GetActiveSpace lst->str I J P P1 P2 PTLST TOBJ X) (vl-load-com) ;; Lee Mac ~ 09.04.10 (defun GetActiveSpace (doc) (if (or (eq AcModelSpace (vla-get-ActiveSpace doc)) (eq :vlax-true (vla-get-MSpace doc))) (vla-get-ModelSpace doc) (vla-get-PaperSpace doc))) (defun lst->str (lst del) (if (cdr lst) (strcat (car lst) del (lst->str (cdr lst) del)) (car lst))) (while (and (setq p1 (getpoint "\nPick First Point <Exit> : ")) (setq p2 (getpoint "\nPick Second Point <Exit> : " p1))) (setq ptLst (cons (list p1 p2) ptLst))) (if (setq p (getpoint "\nPick Point for Table : ")) (progn (setq tObj (vla-AddTable (GetActiveSpace (vla-get-ActiveDocument (vlax-get-acad-object))) (vlax-3D-point p) (+ 2 (length ptLst)) 4 (* 1.5 (getvar 'TEXTSIZE)) (* 12.0 (getvar 'TEXTSIZE)))) (vla-SetText tObj 0 0 "Point Data") ( (lambda ( i ) (mapcar (function (lambda (x) (vla-SetText tObj 1 (setq i (1+ i)) x))) '("Number" "Point 1" "Point 2" "Length"))) -1) ( (lambda ( i ) (mapcar (function (lambda (x) (setq i (1+ i)) ( (lambda ( j ) (mapcar (function (lambda (y) (vla-SetText tObj i (setq j (1+ j)) y))) (list (itoa (1- i)) (lst->str (mapcar (function rtos) (car x)) ",") (lst->str (mapcar (function rtos) (cadr x)) ",") (rtos (distance (car x) (cadr x)))))) -1))) PtLst)) 1))) (princ)) Quote
noyjoreb Posted April 9, 2010 Author Posted April 9, 2010 i have a code of lisp here, i saw here also, this is what i want to modify... the lisp extract data, but only i want to create another column in this table as "Length" from each point... (defun c:tabord(/ aCen cAng cCen cPl cRad cReg fDr it lCnt lLst mSp pCen pT1 pT2 ptLst R tHt tLst vlaPl vlaTab vLst cTxt oldCol nPl clFlg *error*) (vl-load-com) (defun Extract_DXF_Values(Ent Code) (mapcar 'cdr (vl-remove-if-not '(lambda(a)(=(car a)Code)) (entget Ent))) ); end of (defun *error*(msg) (setvar "CMDECHO" 1) (princ) ); end of *error* (if (and (setq cPl(entsel "\nSelect LwPoliline > ")) (= "LWPOLYLINE"(car(Extract_DXF_Values(car cPl)0))) ); end and (progn (setq vlaPl(vlax-ename->vla-object(car cPl)) ptLst(mapcar 'append (setq vLst(Extract_DXF_Values(car cPl)10)) (mapcar 'list(Extract_DXF_Values(car cPl)42))) lLst '("A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q" "R" "S" "T" "U" "V" "W" "X" "Y" "Z") r 2 lCnt 0 tLst '((1 0 "Point")(1 1 "X-Coordinate")(1 2 "Y-Coordinate")(1 3 "Radius")) mSp(vla-get-ModelSpace (vla-get-ActiveDocument (vlax-get-acad-object))) tHt(getvar "TEXTSIZE") ); end setq (setvar "CMDECHO" 0) (foreach vert ptLst (setq vert(trans vert 0 1) tLst(append tLst (list(list r 0 (nth lCnt lLst)) (list r 1(rtos(car vert)2 4)) (list r 2(rtos(cadr vert)2 4)) (list r 3 "")))) (if(and (/= 0.0(last vert)) (setq pt1(vlax-curve-GetPointAtParam vlaPl lCnt)) (setq pt2(vlax-curve-GetPointAtParam vlaPl(1+ lCnt))) ); end and (setq r(1+ r) cRad(abs(/(distance pt1 pt2) 2(sin(/(* 4(atan(abs(last vert))))2)))) aCen(vlax-curve-GetPointAtParam vlaPl(+ 0.5 lCnt)) fDr(vlax-curve-getFirstDeriv vlaPl (vlax-curve-getParamAtPoint vlaPl aCen)) pCen(trans (polar aCen(-(if(minusp(last vert)) pi(* 2 pi)) (atan(/(car fDr)(cadr fDr))))cRad)0 1) tLst(append tLst(list (list r 0 "center") (list r 1(rtos(car pCen)2 4)) (list r 2(rtos(cadr pCen)2 4)) (list r 3(rtos cRad 2 4)))) ); end setq ); end if (setq r(1+ r) lCnt(1+ lCnt)) ); end foreach (setq vlaTab(vla-AddTable mSp (vlax-3D-point '(0 0 0)) (+ 1(/(length tLst)4)) 4 (* 3 tHt)(* 18 tHt))) (foreach i tLst (vl-catch-all-apply 'vla-SetText(cons vlaTab i)) (vla-SetCellTextHeight vlaTab(car i)(cadr i)tHt) (vla-SetCellAlignment vlaTab(car i)(cadr i)acMiddleCenter) ); end foreach (vla-DeleteRows vlaTab 0 1) (princ "\n>> ") (command "_.copybase" (trans '(0 0 0)0 1)(entlast) "") (command "_.erase" (entlast) "") (command "_.pasteclip" pause) (if(= :vlax-true(vla-get-Closed vlaPl)) (progn (setq nPl(vla-Copy vlaPl)) (command "_.region" (entlast) "") (setq cCen(vlax-get(setq cReg (vlax-ename->vla-object(entlast)))'Centroid)) (vla-Delete cReg) (setq clFlg T) ); end progn ); end if (setq lCnt 0) (foreach v vLst (if clFlg (setq cAng(angle cCen(trans v 0 1)) iPt(polar v cAng (* 2 tHt))) (setq fDr(vlax-curve-getFirstDeriv vlaPl (vlax-curve-getParamAtPoint vlaPl v)) iPt(trans (polar v(-(* 2 pi)(atan(/(car fDr)(cadr fDr)))) (* 2 tHt))0 1) ); end if ); end if (setq cTxt(vla-AddText mSp(nth lCnt lLst) (vlax-3d-point iPt) tHt) lCnt(1+ lCnt) ); end setq (setq oldCol(getvar "CECOLOR")) (setvar "CECOLOR" "1") (command "_.circle" v (/ tHt 3)) (setvar "CECOLOR" oldCol) ); end foreach (setvar "CMDECHO" 1) ); end progn (princ "\n It isn't LwPolyline! Quit. ") ); end if (princ) ); end of c:tabordAttached Images tnx in advance... Quote
Lee Mac Posted April 9, 2010 Posted April 9, 2010 Does my code not satisfy your initial request? Quote
noyjoreb Posted April 9, 2010 Author Posted April 9, 2010 its great... but i want sir that coordinates have its own column... coz i want to extract that data in excel for sum calculation... tnx for your reply sir Quote
alanjt Posted April 9, 2010 Posted April 9, 2010 Please post your code within in code tags. http://www.cadtutor.net/forum/showthread.php?t=9184 Quote
BlackAlnet Posted April 9, 2010 Posted April 9, 2010 Why dont calculate the lenght??? If you have(as i see) coordinates and angle? 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.