Discussion:
Modelspace viewport count by activex ...
(too old to reply)
Rudy Tovar
2003-09-17 16:30:30 UTC
Permalink
So what's new, yeah that's not the only screwy function.

Seems to be something missing...not your code.
Has anyone else found the results bogus or unreliable?
(vla-get-count
(vla-get-viewports
(vla-get-activedocument
(vlax-get-acad-object)
)
)
)
I have a drawing with 4 modelspace vports; *NO* viewports in paperspace (
aside from paperspace itself ), yet the above code reports 27. I've
toggled
the active space back and forth, re-opened the dwg. Done an audit /
recover
etc. No change.
Other drawings correctly report the modelspace vport count.
Is it a flaky method or am I misinterpreting the results / failing to
understand the vla-get-viewports method ( collection of all <modelspace>
viewports in the drawing )?
(vla-get-count
(vla-get-viewports DBXDOC)
)
but the same values ( one would hope ) are realized opening the dwg in the
editor and using
(vla-get-count
(vla-get-viewports
(vla-get-activedocument
(vlax-get-acad-object)
)
)
)
Thanks for any enlightening thoughts fellow lithpers.
Michael.
Rudy Tovar
2003-09-17 16:39:39 UTC
Permalink
Just so you know, I'm not trying to be funny, but doesn't seem everything is
running as smooth as it should.

They (Autodesk) wrote a disclaimer regarding the functions they found to be
flawed, leaving us the rest to find.
Post by Rudy Tovar
So what's new, yeah that's not the only screwy function.
Seems to be something missing...not your code.
Has anyone else found the results bogus or unreliable?
(vla-get-count
(vla-get-viewports
(vla-get-activedocument
(vlax-get-acad-object)
)
)
)
I have a drawing with 4 modelspace vports; *NO* viewports in paperspace (
aside from paperspace itself ), yet the above code reports 27. I've
toggled
the active space back and forth, re-opened the dwg. Done an audit /
recover
etc. No change.
Other drawings correctly report the modelspace vport count.
Is it a flaky method or am I misinterpreting the results / failing to
understand the vla-get-viewports method ( collection of all <modelspace>
viewports in the drawing )?
(vla-get-count
(vla-get-viewports DBXDOC)
)
but the same values ( one would hope ) are realized opening the dwg in the
editor and using
(vla-get-count
(vla-get-viewports
(vla-get-activedocument
(vlax-get-acad-object)
)
)
)
Thanks for any enlightening thoughts fellow lithpers.
Michael.
ruul morawetz
2003-09-17 16:41:43 UTC
Permalink
Has anyone else found the results bogus or unreliable?
didn't test for long but here's what i noticed:

tilemode 1, vports from 1 to 4 - function returns 1 (last state)
tm 0 - function returns 4

so the function only returns the correct count when switching tilemode
(vanilla 2004 e-international)

same with saved viewport configurations.
tilemode 1 - vports saved & changed
after switching tilemode correct count of sum of all viewports (active
plus saved)

and: reliable so far (10 minutes ;-).

btw has nothing to do with LAYOUTREGENCTL
--
ruul
michael puckett
2003-09-17 16:42:37 UTC
Permalink
As much as I might enjoy jumping on the "bash Autodesk" wagon, it appears that
the dwg does have 27 vport objects:

I ran this:

(vlax-for viewport
(vla-get-viewports
(vla-get-activedocument
(vlax-get-acad-object)
)
)
(print
(vl-remove-if 'null
(mapcar
'(lambda (x) (if (member (car x) '(-1 0 5)) x))
(entget (vlax-vla-object->ename viewport))
)
)
)
)

and this was the result:

((-1 . <Entity name: 4091ef10>) (0 . "VPORT") (5 . "A1E2"))
((-1 . <Entity name: 4091ef18>) (0 . "VPORT") (5 . "A1E3"))
((-1 . <Entity name: 4091ef20>) (0 . "VPORT") (5 . "A1E4"))
((-1 . <Entity name: 4091ef28>) (0 . "VPORT") (5 . "A1E5"))
((-1 . <Entity name: 4091ef30>) (0 . "VPORT") (5 . "A1E6"))
((-1 . <Entity name: 4091ef38>) (0 . "VPORT") (5 . "A1E7"))
((-1 . <Entity name: 4091ef40>) (0 . "VPORT") (5 . "A1E8"))
((-1 . <Entity name: 4091ef48>) (0 . "VPORT") (5 . "A1E9"))
((-1 . <Entity name: 4091ef50>) (0 . "VPORT") (5 . "A1EA"))
((-1 . <Entity name: 4091ef58>) (0 . "VPORT") (5 . "A1EB"))
((-1 . <Entity name: 4091ef60>) (0 . "VPORT") (5 . "A1EC"))
((-1 . <Entity name: 4091ef68>) (0 . "VPORT") (5 . "A1ED"))
((-1 . <Entity name: 4091ef70>) (0 . "VPORT") (5 . "A1EE"))
((-1 . <Entity name: 4091ef78>) (0 . "VPORT") (5 . "A1EF"))
((-1 . <Entity name: 4091ef80>) (0 . "VPORT") (5 . "A1F0"))
((-1 . <Entity name: 4091ef88>) (0 . "VPORT") (5 . "A1F1"))
((-1 . <Entity name: 4091ef90>) (0 . "VPORT") (5 . "A1F2"))
((-1 . <Entity name: 4091ef98>) (0 . "VPORT") (5 . "A1F3"))
((-1 . <Entity name: 4091efa0>) (0 . "VPORT") (5 . "A1F4"))
((-1 . <Entity name: 4091efa8>) (0 . "VPORT") (5 . "A1F5"))
((-1 . <Entity name: 4091efb0>) (0 . "VPORT") (5 . "A1F6"))
((-1 . <Entity name: 4091efb8>) (0 . "VPORT") (5 . "A1F7"))
((-1 . <Entity name: 4091f000>) (0 . "VPORT") (5 . "A1F8"))
((-1 . <Entity name: 40926ef0>) (0 . "VPORT") (5 . "BA6E"))
((-1 . <Entity name: 40926ef8>) (0 . "VPORT") (5 . "BA6F"))
((-1 . <Entity name: 40926f00>) (0 . "VPORT") (5 . "BA70"))
((-1 . <Entity name: 40926f08>) (0 . "VPORT") (5 . "BA71"))

Why there are 27 in the dwg when modelspace only sports 4 (and none in
paperspace) is a mystery at this point. Residual artifacts from earlier vport
command sequences?

Hmmmm ...

"Rudy Tovar" <***@cadentitynospam.com> wrote in message news:***@in.WebX.maYIadrTaRb...
So what's new, yeah that's not the only screwy function.

Seems to be something missing...not your code.
Has anyone else found the results bogus or unreliable?
< snippage >
Mark Propst
2003-09-17 19:20:42 UTC
Permalink
saved for undo?
Post by michael puckett
As much as I might enjoy jumping on the "bash Autodesk" wagon, it appears that
michael puckett
2003-09-17 16:54:46 UTC
Permalink
Thanks Luis, but I'm writing an auditing program for our company using
objectdbx :)

"Luis Esquivel" <www.draftteam.com> wrote in message news:***@WebX.maYIadrTaRb...
why not use: (vports)
Doug Broad
2003-09-17 17:28:05 UTC
Permalink
Michael,
Do you want the number of paperspace viewports? If so then
you don't want vla-get-viewports. Viewports are objects that
contain the view settings of vports in model space. Each saved
viewport configuration has a number of viewports associated with
it. The active viewport configuration also (I think) has a copy
of the viewports that have been saved. There is also a relationship
between layouts and model space viewports but I don't know
the specifics.
Does that help?
Post by michael puckett
Thanks Luis, but I'm writing an auditing program for our company using
objectdbx :)
why not use: (vports)
Luis Esquivel
2003-09-17 17:32:44 UTC
Permalink
Also,

I run the -vports command and save the configuration to "test"

then...

(tblnext "vport" "test")
(setq vla_vport (vlax-ename->vla-object (tblobjname "vport" "test")))

(vla-delete vla_vport) <= but does not work....
michael puckett
2003-09-17 17:40:04 UTC
Permalink
Hi Doug,

What I'm trying to do is get the modelspace vport count.

But - your info helped. Lots. Said drawing has 12 named viewports in
modelspace ( including the *Active* Viewport, which sports 4 ).

Between all of the named viewports there are precisely 27 possible vports.

THANKS :)

( and thanks to Luis and Rudy who prompted me to think of other things too ).

"Doug Broad" <***@nash.cc.nc.us> wrote in message news:***@in.WebX.maYIadrTaRb...
Michael,
Do you want the number of paperspace viewports? If so then
you don't want vla-get-viewports. Viewports are objects that
contain the view settings of vports in model space. Each saved
viewport configuration has a number of viewports associated with
it. The active viewport configuration also (I think) has a copy
of the viewports that have been saved. There is also a relationship
between layouts and model space viewports but I don't know
the specifics.
Does that help?
Luis Esquivel
2003-09-17 17:43:22 UTC
Permalink
Michael,

return the number of viewports in model:

(setvar "tilemode" 1)
(length (vports))
Post by michael puckett
What I'm trying to do is get the modelspace vport count.
michael puckett
2003-09-17 17:44:47 UTC
Permalink
B y o b j e c t d b x .

But thanks :)

"Luis Esquivel" <www.draftteam.com> wrote in message news:***@in.WebX.maYIadrTaRb...
Michael,

return the number of viewports in model:

(setvar "tilemode" 1)
(length (vports))
Post by michael puckett
What I'm trying to do is get the modelspace vport count.
Luis Esquivel
2003-09-17 17:49:42 UTC
Permalink
Sorry SIR I did not read your previous... it won't happen again... I
promised!... cross my heart! ;-)
Post by michael puckett
B y o b j e c t d b x .
But thanks :)
Michael,
(setvar "tilemode" 1)
(length (vports))
Post by michael puckett
What I'm trying to do is get the modelspace vport count.
michael puckett
2003-09-17 17:55:15 UTC
Permalink
No worries mang! Appreciate you dropping by my thread; cheers :)

"Luis Esquivel" <www.draftteam.com> wrote in message news:***@in.WebX.maYIadrTaRb...

Sorry SIR I did not read your previous... it won't happen again... I
promised!... cross my heart! ;-)
michael puckett
2003-09-17 17:43:23 UTC
Permalink
Oops, Ruul too :)

"michael puckett" <***@m.sux> wrote in message news:***@in.WebX.maYIadrTaRb...

< snip >

( and thanks to Luis and Rudy who prompted me to think of other things too ).

< snip >
ruul morawetz
2003-09-18 05:27:32 UTC
Permalink
Something else: via DBX this won't be an issue I assume, but when using
either of your approaches in an open drawing how do you guarantee that
you really get the current state from AutoCAD?

the 1st function [using (vla-get-count ...] and also the 2nd one
[stepping through viewport collection] return a wrong result (1st: wrong
number, 2nd: nil) when VPORTS is used in MS to save/delete/change the
current configuration.
Toggling of TILEMODE to refresh and get the correct number was necessary
for me.

(vports) returns different lists, too. all data present but the
numbering is different.
(3 .. 4 .. 2 .. 5 ..) versus (2 .. 3 .. 4 .. 5 ..)

I haven't noticed that behaviour before....
and: as my old'n'rusty (vports) using functions still work, I don't
worry too much. ;-)
--
ruul
(getbreakfast "bakery" no_delay)
michael puckett
2003-09-18 15:31:57 UTC
Permalink
I cannot think of any advantage using activex over vanilla in the case of
determining the number of vports in modelspace *IF* the dwg is open in the
AutoCAD editor. I would use (length (vports)) < in the proper space of course
myself.
I have found that in order to get reliable vport count results using activex
in the AutoCAD editor < on the active document > you must toggle tilemode
prior to the count < regen, regenall is not enough to force the database to
update >.

Finally, this ...

(defun OBJDBX-GetVportCount ( DBXDOC / count )
; DBXDOC must be a valid ObjectDBX,
; object and a valid doc must be opened
; prior to this function call. No error
; checking is employed in this function
; in the interests of performance
(setq count 0)
(vlax-for vport (vla-get-viewports DBXDOC)
(if (eq "*ACTIVE" (strcase (vla-get-name vport)))
(setq count(1+ count))
)
)
count
)

Has proven reliable for objectdbx queries so far < 1 day of use >.

Cheers.

"ruul morawetz" <***@_bigfoot.com> wrote in message news:***@in.WebX.maYIadrTaRb...
Something else: via DBX this won't be an issue I assume, but when using
either of your approaches in an open drawing how do you guarantee that
you really get the current state from AutoCAD?

the 1st function [using (vla-get-count ...] and also the 2nd one
[stepping through viewport collection] return a wrong result (1st: wrong
number, 2nd: nil) when VPORTS is used in MS to save/delete/change the
current configuration.
Toggling of TILEMODE to refresh and get the correct number was necessary
for me.

(vports) returns different lists, too. all data present but the
numbering is different.
(3 .. 4 .. 2 .. 5 ..) versus (2 .. 3 .. 4 .. 5 ..)

I haven't noticed that behaviour before....
and: as my old'n'rusty (vports) using functions still work, I don't
worry too much. ;-)

--
ruul
(getbreakfast "bakery" no_delay)
michael puckett
2003-09-17 18:06:16 UTC
Permalink
While this may not be pretty it works ...

(setq Count 0)
(vlax-for vport (vla-get-viewports OBJDBX)
(if (eq "*ACTIVE" (strcase (vla-get-name vport)))
(setq Count (1+ Count))
)
)

I use 'vlax-dump-object quite extensively, it is most useful. Between it, the
object model map and my little atoms.vlx app there are not too many secrets :)

Thanks again Doug.

"Doug Broad" <***@nash.cc.nc.us> wrote in message news:***@in.WebX.maYIadrTaRb...
Glad to help.
Look at the object model for more "good" info and you might
find this revealing:

(vlax-map-collection
(vla-get-viewports
(vla-get-activedocument
(vlax-get-acad-object)))
'vlax-dump-object)
Doug Broad
2003-09-17 18:09:06 UTC
Permalink
That seems the best technique. The current configuration is a
viewport and if split into other viewports, each viewport has
the same name, "*ACTIVE"....

You're welcome.
Post by michael puckett
While this may not be pretty it works ...
(setq Count 0)
(vlax-for vport (vla-get-viewports OBJDBX)
(if (eq "*ACTIVE" (strcase (vla-get-name vport)))
(setq Count (1+ Count))
)
)
I use 'vlax-dump-object quite extensively, it is most useful. Between it, the
object model map and my little atoms.vlx app there are not too many secrets :)
Thanks again Doug.
Glad to help.
Look at the object model for more "good" info and you might
(vlax-map-collection
(vla-get-viewports
(vla-get-activedocument
(vlax-get-acad-object)))
'vlax-dump-object)
Eric Schneider
2003-09-18 23:26:36 UTC
Permalink
I like dbview.arx too but I don't think it works in 2004.
--

Regards,
Eric S.
A2k/W2k
Luis
2003-09-18 23:33:51 UTC
Permalink
Eric,

I think you can email Shaan Hurley and ask him for the A2004 version.
Post by Eric Schneider
I like dbview.arx too but I don't think it works in 2004.
--
Regards,
Eric S.
A2k/W2k
Doug Broad
2003-09-17 18:03:11 UTC
Permalink
Glad to help.
Look at the object model for more "good" info and you might
find this revealing:

(vlax-map-collection
(vla-get-viewports
(vla-get-activedocument
(vlax-get-acad-object)))
'vlax-dump-object)
Post by michael puckett
Hi Doug,
What I'm trying to do is get the modelspace vport count.
But - your info helped. Lots. Said drawing has 12 named viewports in
modelspace ( including the *Active* Viewport, which sports 4 ).
Between all of the named viewports there are precisely 27 possible vports.
THANKS :)
( and thanks to Luis and Rudy who prompted me to think of other things too ).
Michael,
Do you want the number of paperspace viewports? If so then
you don't want vla-get-viewports. Viewports are objects that
contain the view settings of vports in model space. Each saved
viewport configuration has a number of viewports associated with
it. The active viewport configuration also (I think) has a copy
of the viewports that have been saved. There is also a relationship
between layouts and model space viewports but I don't know
the specifics.
Does that help?
Rudy Tovar
2003-09-17 17:18:50 UTC
Permalink
So what you're saying is that there's 23 hidden vports or stored?
Post by michael puckett
Thanks Luis, but I'm writing an auditing program for our company using
objectdbx :)
why not use: (vports)
Luis Esquivel
2003-09-17 16:53:48 UTC
Permalink
why not use: (vports)
Loading...