Jump to content

Recommended Posts

Posted

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

Posted
...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)
)

Posted
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.

Posted
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.

Posted
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

 

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'~

Posted
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....

Posted
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.

Posted
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.....?

Posted
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.

Posted

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.

Posted
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))))
    )

Posted

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")

Posted

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))

Posted
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.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...