cabltv1 Posted January 29, 2009 Share Posted January 29, 2009 Please help! I need a a lisp routine to do the following... 1) Select one end of a Line or Pline (both are used), pause to select a block, then put the coordinates into the selected block attribute:Tag named "PT1". 2) Select other end of a Line or Pline (both are used), pause to select a block, then put the coordinates into the selected block attribute:Tag named "PT2". Much thanks to anyone that can help. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 29, 2009 Share Posted January 29, 2009 Will these be two different blocks to contain the start and endpoints? Also - could the user not just select the whole line with one pick? Quote Link to comment Share on other sites More sharing options...
cabltv1 Posted January 29, 2009 Author Share Posted January 29, 2009 1 block with 2 seperate TAGS that need to be filled in "PT1" and "PT2". Picking the line once will be fine. I need the coordinates in the TAGS to be in the following format... 2470263'-4.83",7002825'-4.30",0.00" This is twice today you have helped me. You helped earlier with picking a block to get the coordinates from then selecting another block to put the coordinates into. It works great except for one thing. I need it to have the below format... 2470263'-4.83",7002825'-4.30",0.00" Thanks again Lee. Your help is greatly appreciated. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 29, 2009 Share Posted January 29, 2009 This for now: (defun c:lcoord (/ lEnt bEnt vEnt sPt ePt aEnt aEntLst) (vl-load-com) (if (and (setq lEnt (car (entsel "\nSelect Curve > "))) (member (cdr (assoc 0 (entget lEnt))) '("LINE" "POLYLINE" "LWPOLYLINE" "SPLINE" "ARC")) (setq bEnt (car (entsel "\nSelect Destination Block > "))) (= (cdr (assoc 0 (entget bEnt))) "INSERT") (= (cdr (assoc 66 (entget bEnt))) 1)) (progn (setq vEnt (vlax-ename->vla-object lEnt) sPt (vlax-curve-getStartPoint vEnt) ePt (vlax-curve-getEndPoint vEnt) aEnt (entnext bEnt)) (while (/= "SEQEND" (cdr (assoc 0 (setq aEntLst (entget aEnt))))) (cond ((= "PT1" (cdr (assoc 2 aEntLst))) (setq aEntLst (subst (cons 1 (strcat (rtos (car sPt) 2 2) "," (rtos (cadr sPt) 2 2) "," (rtos (caddr sPt) 2 2))) (assoc 1 aEntLst) aEntLst)) (entmod aEntLst)) ((= "PT2" (cdr (assoc 2 aEntLst))) (setq aEntLst (subst (cons 1 (strcat (rtos (car ePt) 2 2) "," (rtos (cadr ePt) 2 2) "," (rtos (caddr ePt) 2 2))) (assoc 1 aEntLst) aEntLst)) (entmod aEntLst))) (setq aEnt (entnext aEnt))))) (command "_regenall") (princ)) Will work on Arc, spline, line, pline, lwpline Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 29, 2009 Share Posted January 29, 2009 I need the coordinates in the TAGS to be in the following format...2470263'-4.83",7002825'-4.30",0.00" Do you want me to convert coords to feet/inches? Or, if the coord is say: 3.5, 4.5, 6.5 then 3'-5",4'-5",6'-5" ? Quote Link to comment Share on other sites More sharing options...
cabltv1 Posted January 29, 2009 Author Share Posted January 29, 2009 Man, your the best. It works like a charm. As for the second part, I need the coordinates in Feet and Inches (see example below). The example below has a space on both sides of the comma but I can live without the spaces. 2470260'-2.45" , 7002781'-5.38" Thanks again! I have been struggling with this for a couple of days. Quote Link to comment Share on other sites More sharing options...
cabltv1 Posted January 29, 2009 Author Share Posted January 29, 2009 Lee, Could it be a setting in AutoCAD that I need to change to make the format fill out correctly? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 29, 2009 Share Posted January 29, 2009 The space isn't too hard to accomodate - but as for the conversion, I think you may be able to change the units - although I am not sure if the units that I am retrieving have to be constant. But in any case, engineering a code to convert to feet and inches shouldn't be too hard. I'll see what I can do. May have to be later though - I have a few lectures right now Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 29, 2009 Share Posted January 29, 2009 You can change the units that you view the coordinates in, by typing "units" into the command line and changing to architectural. But the return when I retrieve the start and endpoints of the line are still the same (possibly in mm?). Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 29, 2009 Share Posted January 29, 2009 Ahh, I have sussed it. The output that I retrieve is in inches. Quote Link to comment Share on other sites More sharing options...
cabltv1 Posted January 29, 2009 Author Share Posted January 29, 2009 Lee, I tried different "Unit" settings but it did not seem to change the attribute before or after I ran the routine. The code you gave me is in inches but is in this format 8.5 instead of this format 8'-6.00" I am very greatfull for all of your help! You saved me a lot of trial and error. I can live with the current routine the way it currently works. Thanks again. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 29, 2009 Share Posted January 29, 2009 I'll work on it Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 29, 2009 Share Posted January 29, 2009 The code you gave me is in inches but is in this format 8.5 instead of this format 8'-6.00" When you say it is in inches, do you mean the return is 8.5 inches? i.e. 0'-8.50" or 8.5 feet to be formatted as: 8'-6.00" Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 29, 2009 Share Posted January 29, 2009 If the result is indeed in inches, this should work: (defun c:lcoord (/ lEnt bEnt vEnt sPt ePt aEnt aEntLst) (vl-load-com) (if (and (setq lEnt (car (entsel "\nSelect Curve > "))) (member (cdr (assoc 0 (entget lEnt))) '("LINE" "POLYLINE" "LWPOLYLINE" "SPLINE" "ARC")) (setq bEnt (car (entsel "\nSelect Destination Block > "))) (= (cdr (assoc 0 (entget bEnt))) "INSERT") (= (cdr (assoc 66 (entget bEnt))) 1)) (progn (setq vEnt (vlax-ename->vla-object lEnt) sPt (vlax-curve-getStartPoint vEnt) ePt (vlax-curve-getEndPoint vEnt) aEnt (entnext bEnt)) (while (/= "SEQEND" (cdr (assoc 0 (setq aEntLst (entget aEnt))))) (cond ((= "PT1" (cdr (assoc 2 aEntLst))) (setq aEntLst (subst (cons 1 (strcat (in2ft (car sPt)) (chr 32) "," (chr 32) (in2ft (cadr sPt)) (chr 32) "," (chr 32) (in2ft (caddr sPt)))) (assoc 1 aEntLst) aEntLst)) (entmod aEntLst)) ((= "PT2" (cdr (assoc 2 aEntLst))) (setq aEntLst (subst (cons 1 (strcat (in2ft (car ePt)) (chr 32) "," (chr 32) (in2ft (cadr ePt)) (chr 32) "," (chr 32) (in2ft (caddr ePt)))) (assoc 1 aEntLst) aEntLst)) (entmod aEntLst))) (setq aEnt (entnext aEnt))))) (command "_regenall") (princ)) (defun in2ft (num / ft in) (setq ft (fix (/ num 12.0)) in (rem num 12.0)) (strcat (rtos ft 2 2) (chr 39) (chr 45) (rtos in 2 2) (chr 34))) Quote Link to comment Share on other sites More sharing options...
cabltv1 Posted January 29, 2009 Author Share Posted January 29, 2009 Lee, You did it once again. Your amazing! Thanks much Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 29, 2009 Share Posted January 29, 2009 Lee,You did it once again. Your amazing! Thanks much Thanks cabltv - glad it works and will save some time Any other questions ~ just ask Quote Link to comment Share on other sites More sharing options...
cabltv1 Posted July 21, 2009 Author Share Posted July 21, 2009 Lee, Your last post for this thread works great except. I was wondering what portion of the code I could modify to eliminate some of the zeros? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted July 21, 2009 Share Posted July 21, 2009 Did we not rectify this here: http://www.cadtutor.net/forum/showthread.php?t=38357 ? Quote Link to comment Share on other sites More sharing options...
cabltv1 Posted July 21, 2009 Author Share Posted July 21, 2009 Lee, That is the code I used in the example. It works perfectly but I didn't notice the trailing zeros at the time. I just tried that code again to make sure and they are still there. In the example the figure for PT1 is 983.00'-0.74", -2885.00'-3.90", 0.00'-0.00". I am trying to remove the (.00) in red. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted July 21, 2009 Share Posted July 21, 2009 Ok, that will not be from the LISP I don't think then - check your setting of DIMZIN Quote Link to comment Share on other sites More sharing options...
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.