DWF Viewer (Read Only)
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SetView() from javascript in Express

22 REPLIES 22
Reply
Message 1 of 23
Anonymous
712 Views, 22 Replies

SetView() from javascript in Express

In whip and volo, I could set the current view rectangle (SetAndDrawView) via javascript. In Express, I can get from the AdViewer object to an AdPageViewer object(via .Viewer - [aside - didn't see it mentioned in the doc, just using ole viewer]) but it gives me an IAdReaderViewer interface. I was hoping for an IAdPageViewer interface where I could try .SetView().

Is there a way in javascript with Express to set the current view/zoom rectangle?

thanks
22 REPLIES 22
Message 2 of 23
Anonymous
in reply to: Anonymous

Here is a sample code:


Private Sub Form_Load()


    CAdViewer1.SourcePath = "C:/tmp.dwf"


End Sub


 


Private Sub Command1_Click()


    Dim pv as IAdPageViewer


    Set pv = CAdViewer.Viewer


    pv.SetView 0, 0, 10, 10 'Set a zoom window


    Dim cpv as CAdPageView


    Set cpv = pv.View


    'Extract the current display coordinates.


    Debug.Print cpv.Bottom &"," &cpv.Left &","
&cpv.Right &"," &cpv.Top


End Sub


 


cheers,
-Thilak


 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
In
whip and volo, I could set the current view rectangle (SetAndDrawView) via
javascript. In Express, I can get from the AdViewer object to an AdPageViewer
object(via .Viewer - [aside - didn't see it mentioned in the doc, just using
ole viewer]) but it gives me an IAdReaderViewer interface. I was hoping for an
IAdPageViewer interface where I could try .SetView().

Is there a way in javascript with Express to set the current view/zoom
rectangle?

thanks

Message 3 of 23
Anonymous
in reply to: Anonymous

But, in JavaScript, you cannot select a different interface, and the default interface returned by .Viewer is IAdReaderViewer.

Are you saying that this cannot be done from javascript?

thanks,
Message 4 of 23
Anonymous
in reply to: Anonymous

<object
classid="clsid:A662DA7E-CCB7-4743-B71A-D817F6D575DF" id="AdView" width="800"
height="500">
</object>

<SCRIPT LANGUAGE="javascript">

    AdView.Viewer.SetView
(0,0,10,10)

</<SCRIPT>


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
But,
in JavaScript, you cannot select a different interface, and the default
interface returned by .Viewer is IAdReaderViewer.

Are you saying that this cannot be done from javascript?

thanks,

Message 5 of 23
Anonymous
in reply to: Anonymous

I don't see this in the api documentation.

What units are in the SetView call and in what order? I changed my SetView(left, right, bottom, top) from whip/volo to SetView( left, bottom, right, top) like oleview says for express. But when I give the corners specified in, for example, my "INITIAL" view in the dwf file I end up lost in space. Seemed like my corners of(Left:-13000, Bottom:-8000, Right:13000, Top:8000) seemed off by a factor of 1000 (plus some offset) for the SetView call. I need a call of somewhere around SetView( 0, 0, 10, 10 ) to get my (-13000, -8000, 13000, 8000) corners.
Message 6 of 23
Anonymous
in reply to: Anonymous


The parameters are left, bottom,
right, top and they are in paper units (in or mm), not drawing units.


 


You can also set the view using
the named view collection. I have included some samples below.



size=2>
 



size=2>function InitialView ()
{



size=2>  AdView.Viewer.WaitForPageLoaded();
  AdView.Viewer.View =
AdView.Viewer.NamedViews.Item ("INITIAL");
}
 
function ViewTour
()
{



size=2>  AdView.Viewer.WaitForPageLoaded();



size=2>  for (i = 1; i <= AdView.Viewer.NamedViews.Count; i++

  {
    view =
AdView.Viewer.NamedViews.Item(i);
    AdView.Viewer.View
=
view 
    alert(view.name);   
  }
}


 



style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
I
don't see this in the api documentation.

What units are in the SetView call and in what order? I changed my
SetView(left, right, bottom, top) from whip/volo to SetView( left, bottom,
right, top) like oleview says for express. But when I give the corners
specified in, for example, my "INITIAL" view in the dwf file I end up lost in
space. Seemed like my corners of(Left:-13000, Bottom:-8000, Right:13000,
Top:8000) seemed off by a factor of 1000 (plus some offset) for the SetView
call. I need a call of somewhere around SetView( 0, 0, 10, 10 ) to get my
(-13000, -8000, 13000, 8000) corners.

Message 7 of 23
Anonymous
in reply to: Anonymous

Unfortunately, the named views don't apply in my case.
If all I know is the drawing units, how do I know the configuration to paper units that express will be using?

thanks.
Message 8 of 23
Anonymous
in reply to: Anonymous

And, by configuration, I apparently mean conversion to paper units.
Message 9 of 23
Anonymous
in reply to: Anonymous


In a future release the EV API
may be able to transform a point from drawing units to paper units.



style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
And,
by configuration, I apparently mean conversion to paper
units.
Message 10 of 23
Anonymous
in reply to: Anonymous

I don't mind doing the conversion to EV's paper units. I just don't have enough information to go from the information in the dwf, like drawing units, to whatever EV's 'paper units' represent. Can you provide any information about how paper units are calculated so I can convert my coordinates to paper units?
Message 11 of 23
Anonymous
in reply to: Anonymous

The information you need is not available through
the API, other than through the transform point method Ben mentioned, which will
be implemented in the next AEV service pack due soon.


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
I
don't mind doing the conversion to EV's paper units. I just don't have enough
information to go from the information in the dwf, like drawing units, to
whatever EV's 'paper units' represent. Can you provide any information about
how paper units are calculated so I can convert my coordinates to paper
units?
Message 12 of 23
Anonymous
in reply to: Anonymous

So, essentially this is a useless external api function because it relies on internal units that cannot be known to the external api caller?
Message 13 of 23
Anonymous
in reply to: Anonymous

The transform point API allows you to transform
from one coordinate space to another.  You determine the source and
destination coordinate spaces and the point to feed in.  Coordinate spaces
are either drawing (i.e. AutoCAD model space - double space), DWF (i.e Whip
- integer space), paper (i.e. double space in paper units), or screen (i.e.
pixels).

 

You obviously know one about one of the coordinate
spaces (drawing units) or else you would have no information with which to
call SetView() in the first place.  TransformPoint allows you to use your
coordinate space values to generate those that are compatible with other API
calls.

 

If you have no knowledge of any units whatsoever,
then yes, this would be quite useless to you.


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
So,
essentially this is a useless external api function because it relies on
internal units that cannot be known to the external api
caller?
Message 14 of 23
Anonymous
in reply to: Anonymous

You mean the non-existent tranform point api?
Message 15 of 23
Anonymous
in reply to: Anonymous

Um, yeah. 

 

It's implemented in the next service pack, due very
soon.


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
You
mean the non-existent tranform point api?
Message 16 of 23
Anonymous
in reply to: Anonymous


Paper units are, millimeters or
inches. You can ask the page what its units are (I provided an example below).


 


If you produced the dwf then you
know the scale. If the drawing is in feet and the layout scale is 2:1 you know
that 6 inches in paper space (or page units) is equal to 1 foot. I hope
this will work for you.


 


At the same time we understand
the need for a more programmatic solution and it is on the way.



size=2>
 



size=2>function ShowPageUnits()
{
 
AdView.Viewer.WaitForPageLoaded();
  if ( AdView.Viewer.Page.Paper.Units
== 1 )
   
alert("Inches");      
        
  else
if ( AdView.Viewer.Page.Paper.Units == 2 )
   
alert("Millimeters");     



size=2>  



size=2>  else if ( AdView.Viewer.Page.Paper.Units == 0
)
    alert("Unknown");     


}



style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Jeffrey Klug (Autodesk)" <jeffrey dot klug at autodesk dot com>
wrote in message
href="news:ED68917E8F7A019375F9D89FD6EBFAAF@in.WebX.maYIadrTaRb">news:ED68917E8F7A019375F9D89FD6E...
...

Um, yeah. 

 

It's implemented in the next service pack, due
very soon.


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
You
mean the non-existent tranform point
api?
Message 17 of 23
Anonymous
in reply to: Anonymous



Paper units are, millimeters or
inches. You can ask the page what its units are (I provided an example below).


 


If you produced the dwf then you
know the scale. If the drawing is in feet and the layout scale is 2:1 you know
that 6 inches in paper space (or page units) is equal to 1 foot. I hope
this will work for you.


 


At the same time we understand
the need for a more programmatic solution and it is on the way.



size=2>
 



size=2>function ShowPageUnits()
{
 
AdView.Viewer.WaitForPageLoaded();
  if ( AdView.Viewer.Page.Paper.Units
== 1 )
   
alert("Inches");      
        
  else
if ( AdView.Viewer.Page.Paper.Units == 2 )
   
alert("Millimeters");     



size=2>  



size=2>  else if ( AdView.Viewer.Page.Paper.Units == 0
)
    alert("Unknown");     


}



style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
So,
essentially this is a useless external api function because it relies on
internal units that cannot be known to the external api
caller?
Message 18 of 23
Anonymous
in reply to: Anonymous

Paper units are, millimeters or inches. You can ask the page what its units
are (I provided an example below).



If you produced the dwf then you know the scale. If the drawing is in feet
and the layout scale is 2:1 you know that 6 inches in paper space (or page
units) is equal to 1 foot. I hope this will work for you.



At the same time we understand the need for a more programmatic solution and
it is on the way.



function ShowPageUnits()
{
AdView.Viewer.WaitForPageLoaded();
if ( AdView.Viewer.Page.Paper.Units == 1 )
alert("Inches");

else if ( AdView.Viewer.Page.Paper.Units == 2 )
alert("Millimeters");



else if ( AdView.Viewer.Page.Paper.Units == 0 )
alert("Unknown");

}



"hmp" wrote in message
news:f15b81f.10@WebX.maYIadrTaRb...
So, essentially this is a useless external api function because it relies on
internal units that cannot be known to the external api caller?
Message 19 of 23
Anonymous
in reply to: Anonymous

I simply want to set the view to a particular area of the drawing. What I need to do this myself is the coordinate transformation from a coordinate space I might know like drawing units in the DWF file to the exact coordinate space needed for the call to SetView. This doesn't involve what the units are, but rather the relative scale of the two coordinate spaces and an x-y offset for the transformation. Hopefully the upcoming TransformPoint method will correctly transform drawing coordinates as used in the DWF file to the coordinates used in EV's external methods like SetView(), but until then SetView() is a completely useless function because no caller could know the values to provide.

In my opinion, and apparently the authors of Whip and Volo, the natural units to be used in external methods like SetView are simply the drawing units of the DWF, not some (at this point, unknowable) paper units.


Part of what is frustrating is that the crippled functionality of Autodesk Express Viewer is coupled with Autodesk to make Whip and Voloview unavailable. This leaves me in the position of explaining to my customers that to access functionality that had been available since the earliest DWF viewers, each and every one of my customers potential internet users must run the Whip install which I luckily found lying in the recycle bin on my machine. And, well it would be a little easier if an earlier reply said SetView won't work until a later version rather than fruitlessly investing time in exploring it.
Message 20 of 23
Anonymous
in reply to: Anonymous

Should I be concerned that the upcomming TransformPoint method won't actually work from javascript but will be limited to vb and vbscript?

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report