Erroreki Posted June 6, 2023 Share Posted June 6, 2023 (edited) Hi! Avid reader of the forums, first time poster. I have a code with which I'm trying to extract the x and y coordinate of the startpoint of a line to the clipboard for pasting into another program. The problem is that when I run the lisp in Civil 3D it spits out Quote error: bad argument type: "LINE" when running (caddr typelst) on line 6 in the code below. What could cause this. I'm having trouble understanding why it wouldn't be able to grab the type from the list. The code: (vl-load-com) (defun c:copyx1y1 () (setq choice (entsel "Choose the line whose start X and Y you want to copy \n")) (setq entname (car choice)) (setq typelst (assoc 0 (entget entname))) (if (= (caddr typelst) "LINE") (progn (setq startpnt (assoc 10 (entget entname))) (setq x1 (cadr startpnt)) (princ "\n") (princ x1) (princ "\n") (setq y1 (caddr startpnt)) (princ y1) (setq copiedtxt (strcat (rtos x1) "\t" (rtos y1))) (setq result (vlax-invoke (vlax-get (vlax-get (setq htmlfile (vlax-create-object "htmlfile")) 'ParentWindow) 'ClipBoardData) 'SetData "Text" copiedtxt) ) (vlax-release-object htmlfile) copiedtxt ) (progn (princ "The choice is not of type LINE") ) ) (princ) ) Regards, E Edited June 6, 2023 by Erroreki Words missing in sentence 1 Quote Link to comment Share on other sites More sharing options...
Erroreki Posted June 6, 2023 Author Share Posted June 6, 2023 Got it fixed by replacing Quote (caddr typelst) with Quote (cdr typelst) Didn't realise that dotted pair lists' values are called with cdr because it's a dotted PAIR and not a list with three elements per se. E Quote Link to comment Share on other sites More sharing options...
mhupp Posted June 7, 2023 Share Posted June 7, 2023 (edited) Welcome to the forums. Another way is to use ssget in point select mode. so it mimics entsel but only allows you to pick one entity and only what you put in the filter. this will do away with potentially selecting the wrong thing and having to check what you selected is the right thing. (defun c:copyx1y1 (/ SS spt txt x1 yz html) (prompt "Choose the line whose start X and Y you want to copy \n") (if (setq SS (ssget "_+.:E:S" '((0 . "LINE")))) (progn (setq spt (assoc 10 (entget (ssname SS 0)))) (prompt (strcat "\nX: " (setq x1 (rtos (cadr spt))) "\nY: " (setq y1 (rtos (caddr spt))))) (setq txt (strcat x1 " " y1)) (vlax-invoke (vlax-get (vlax-get (setq html (vlax-create-object "htmlfile")) 'ParentWindow) 'ClipBoardData) 'setData "Text" txt) (vlax-release-object html) ) ) (princ) ) Windows has a feature most people don't know/use. Instead of Ctrl + V you can use Windows key + V it will enable Clipboard history. and pop up a small window of all your past clips from that point on. Edited June 7, 2023 by mhupp 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.