Small Fish Posted November 18, 2009 Posted November 18, 2009 Hi I want to use: (setq enaPline (car (entsel "\nSelect paperspace Viewport : "))) (setq VpScaleRatio(vla-get-customscale (vlax-ename->vla-object enaPline))) to find the custom scale of a viewport however I can not use this above code if I make the viewport "mview" then "object" (in other words make viewport from a pline) I think this is because the viewport is also a 'polyline' as well as a 'viewport'. So I guess the way around this is to make a filter using entsel, so that only the viewport is selected rather than the polyline. Is there a way to make a filter (just for 'viewport') using entsel? thanks Quote
rkmcswain Posted November 18, 2009 Posted November 18, 2009 ...however I can not use this above code if I make the viewport "mview" then "object" (in other words make viewport from a pline)I think this is because the viewport is also a 'polyline' as well as a 'viewport'. Sort of. There are still two entities, but they are sort of "linked" together. You can see this by using the LIST command. So I guess the way around this is to make a filter using entsel, so that only the viewport is selected rather than the polyline. Is there a way to make a filter (just for 'viewport') using entsel? thanks You could do something like this. (if (setq ss (ssget '((0 . "VIEWPORT")))) (setq obj (ssname ss 0)) (setq obj nil) ) Quote
alanjt Posted November 18, 2009 Posted November 18, 2009 You should check out my AT:Entsel subroutine. It offers almost all functionality of the dxf filtering in ssget, can ignore locked layers, convert to vla-object, select primary or nested object and accept keywords. Link: http://www.cadtutor.net/forum/showpost.php?p=271389&postcount=26 Quote
rkmcswain Posted November 18, 2009 Posted November 18, 2009 You should check out my AT:Entsel subroutine. It offers almost all functionality of the dxf filtering in ssget, can ignore locked layers, convert to vla-object, select primary or nested object and accept keywords. Link: http://www.cadtutor.net/forum/showpost.php?p=271389&postcount=26 How does this help? I tried using it like this: (AT:Entsel nil nil '("LV" (0 . "VIEWPORT")) nil) ...and I keep getting "Nope, keep trying!" Thanks. Quote
alanjt Posted November 18, 2009 Posted November 18, 2009 How does this help?I tried using it like this: (AT:Entsel nil nil '("LV" (0 . "VIEWPORT")) nil) ...and I keep getting "Nope, keep trying!" Thanks. Is it locked, or a Polyline (clipped viewport)? Works fine for me: Command: (AT:Entsel nil nil '("LV" (0 . "VIEWPORT")) nil) Select object: #<VLA-OBJECT IAcadPViewport2 21612944> I use this routine all the time, I can't imagine why it's not working properly for you. Quote
fixo Posted November 18, 2009 Posted November 18, 2009 HiI want to use: (setq enaPline (car (entsel "\nSelect paperspace Viewport : "))) (setq VpScaleRatio(vla-get-customscale (vlax-ename->vla-object enaPline))) to find the custom scale of a viewport however I can not use this above code if I make the viewport "mview" then "object" (in other words make viewport from a pline) I think this is because the viewport is also a 'polyline' as well as a 'viewport'. So I guess the way around this is to make a filter using entsel, so that only the viewport is selected rather than the polyline. Is there a way to make a filter (just for 'viewport') using entsel? thanks Here is another way (while (not (and (setq entVport (entsel "\nSelect paperspace Viewport : ")) (eq "VIEWPORT" (cdr (assoc 0 (entget (setq enaPline (car entVport)))))))) (princ "\n\t\t>>>\tSelected is not a Viewport, try again\t<<<")) ~'J'~ Quote
rkmcswain Posted November 18, 2009 Posted November 18, 2009 I use this routine all the time, I can't imagine why it's not working properly for you. Because that code is picking up the polyline, not the viewport entity I suppose. The OP had the same problem with (entsel) in general. I can give you the steps to recreate if you need.... Quote
alanjt Posted November 18, 2009 Posted November 18, 2009 Because that code is picking up the polyline, not the viewport entity I suppose. The OP had the same problem with (entsel) in general. I can give you the steps to recreate if you need.... If it's a clipped viewport, a polyline will be atop (attached with reactor) the viewport. One would have to entnext through the selection to get to the actual viewport (if associated with pline). Assoc 330 or 360 would get the actual viewport. Quote
rkmcswain Posted November 18, 2009 Posted November 18, 2009 If it's a clipped viewport, a polyline will be atop (attached with reactor) the viewport. One would have to entnext through the selection to get to the actual viewport (if associated with pline). Assoc 330 or 360 would get the actual viewport. Or you could just do this.....? Quote
alanjt Posted November 18, 2009 Posted November 18, 2009 Or you could just do this.....? I didn't say that wasn't a good option. It just seemed like he was looking for a entsel style selection method. Quote
Small Fish Posted November 18, 2009 Author Posted November 18, 2009 Thanks guys I wanted entsel because I wanted to pick a single entity ie the viewport. I guess I could use (ssget ":s" '((0 . "viewport"))) to get the same result as entsel It seems to me the only possible answer is to use Alan's suggestion ntnext through the selection to get to the actual viewport (if associated with pline). Assoc 330 or 360 would get the actual viewport. Although I have not figured out how to do it yet. This problem seems to be much harder to achieve than I first thought. Quote
alanjt Posted November 18, 2009 Posted November 18, 2009 Thanks guys I wanted entsel because I wanted to pick a single entity ie the viewport. I guess I could use (ssget ":s" '((0 . "viewport"))) to get the same result as entsel It seems to me the only possible answer is to use Alan's suggestion Although I have not figured out how to do it yet. This problem seems to be much harder to achieve than I first thought. (and (setq ent (car (entsel))) (setq vp (cdr (assoc 330 (entget ent)))) ) Quote
alanjt Posted November 18, 2009 Posted November 18, 2009 Using AT:Entsel: (and (setq ent (car (at:entsel nil nil '((0 . "LWPOLYLINE")(102 . "{ACAD_REACTORS")) nil))) (setq vp (cdr (assoc 330 (entget ent)))) ) Not perfect, I'd still check that the assoc 330 matches (0 . "VIEWPORT") Quote
Small Fish Posted November 18, 2009 Author Posted November 18, 2009 eureka - I have it now many thanks (if (setq ss (ssget ":s" '((0 . "viewport")))) (setq enname (ssname ss 0)) (setq enname nil) ) (setq VptObj (vlax-ename->vla-object enname )) (setq VpScaleRatio(vla-get-customscale VptObj)) Quote
alanjt Posted November 18, 2009 Posted November 18, 2009 eureka - I have it now many thanks (if (setq ss (ssget ":s" '((0 . "viewport")))) (setq enname (ssname ss 0)) (setq enname nil) ) (setq VptObj (vlax-ename->vla-object enname )) (setq VpScaleRatio(vla-get-customscale VptObj)) or (and (setq ent (car (entsel))) (eq "VIEWPORT" (cdr (assoc 0 (entget ent)))) (setq obj (vlax-ename->vla-object ent)) (setq scl (vla-get-customscale obj)) ) BTW, with what you have, if you object is not a viewport it will error when trying to convert nil to a vla-object. 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.