aridzv Posted February 24 Posted February 24 (edited) Hi. I have a lisp that get an attribute value from a block and put this value to a Mleader - all in model space. I need to be able to select that block when in paper space from a viewport (the block is visible - click on it) ,get it's attribute values and use them in paper space. the question is - can I click on the object in paper space,make the lisp to get the object properties and use them back in the viewport. I've googled this but could'nt get quite what I need. here is a sample drawing and the lisp I use in model space. thanks, aridzv. *EDIT: in my google search I fount this old thread that mybe can be a start for more talented programmers than me... MLeaderWBlTxt.lspDrawing1.dwg Edited February 24 by aridzv Quote
BIGAL Posted February 24 Posted February 24 If you pick a point in paperspace you can go to model space and using a trans function work out where the point is in Model and then try using (ssget pt). Yes does work. Look up help about trans function. (trans pt 3 0) 1 Quote
aridzv Posted February 24 Author Posted February 24 39 minutes ago, BIGAL said: If you pick a point in paperspace you can go to model space and using a trans function work out where the point is in Model and then try using (ssget pt). Yes does work. Look up help about trans function. (trans pt 3 0) I wrote this: (defun c:test3 ( / pt pt1) (setq pt (getpoint)) ;;get point in paper space (setq pt1 (trans pt 3 0)) (command "._MSPACE") (command "Point" pt1) ) it dosn't put the point exactelly in place. in paper space I snap to node on the object and the point is located in some offset... Quote
aridzv Posted February 26 Author Posted February 26 3 hours ago, BIGAL said: Is you model space in a non World UCS ? no. it is a 3d drawing and it happens when the view is any 3d view (Top Front Right,Top Back Right,etc...). Quote
aridzv Posted February 26 Author Posted February 26 (edited) solved by @Steven P here - thanks. (defun c:test3 ( / e) (getpoint);; get point in paper space on the target object (command "._MSPACE");; move to model space with the currsor "Locked" on the selected point on the target object (setq e (car (last (nentselp (cadr (grread t))))));; get the entity name by the point located on the target object (command "._PSPACE");; back to paper space (princ e);; print the entity name (entget e);; print the entity data ) Edited February 27 by aridzv Quote
aridzv Posted March 1 Author Posted March 1 (edited) another way, Maybe cleaner. (defun c:test33 ( / pt ss entname) (getpoint) ;;get point in paper space on the target object (command "._MSPACE");;move to model space with the currsor "Locked" on the selected point on the target object (setq pt (cadr (grread t)));;get the point where the currser is - "Locked" on the target object (setq ss (ssget pt));; use ssget at point to get selection set with the target object (setq entname(ssname ss 0));; get the entity name from the selection set (the first one in the selection set) (command "._PSPACE");;back to paper space (princ entname);;print the entity name (entget entname);; print the entity data ) Edited March 2 by aridzv Quote
aridzv Posted March 2 Author Posted March 2 On 2/24/2024 at 11:39 PM, BIGAL said: If you pick a point in paperspace you can go to model space and using a trans function work out where the point is in Model and then try using (ssget pt). Yes does work. Look up help about trans function. (trans pt 3 0) it bug's me why it didnn't work, so after some digging I found that it had to be done in tow steps this way: (setq ptps(getpoint)) ;;get point in paper space (setq ptps1 (trans ptps 3 2)) ;Step 1: translate the point from the Paper space DCS (Display Coordinate System) to the DCS of the current model space viewport. (setq ptms (trans ptps1 2 0)) ;Step 2: translate the point from the DCS of the current model space viewport to World (WCS) ;;;;;; ;; can also be in one code line this way: (setq ptms(trans(trans ptps 3 2) 2 0)) ;;;;;; and used this way in the code: (defun c:test33B ( / ptps ptms ss entname) (setq ptps(getpoint) ;;get point in paper space on the target object (setq ptms(trans (trans ptps 3 2) 2 0));; translate the point from paper space to model space. (command "._MSPACE");;move to model space with the model space point on the target object (setq ss (ssget ptms));; use ssget at point to get selection set with the target object (setq entname(ssname ss 0));; get the entity name from the selection set (the first one in the selection set) (command "._PSPACE");;back to paper space (princ entname);;print the entity name (entget entname);; print the entity data ) aridzv. 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.