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

How to Adjust AEV Params Inline

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
257 Views, 2 Replies

How to Adjust AEV Params Inline

All:

 

This is a response to several earlier posts by
"vanceg" and others.  As far as I know, there is no good way to utilize the
WaitForPageLoaded() method of
face="Courier New">AdView.Viewer
when using it inline, as the script
throws an error.  So here'a a little JavaScript code that lets
you set properties for the AdView
object. 

 

The trick is to load an *empty* instance of the
object, and then load the DWF during page load.  This lets us bypass having
to wait an inital DWF load and gives us access to many of the properties as soon
as the empty AdView instance is
loaded.  So a sample bit of code would look like this:

 


size=2><html>
<head></head>
<body>
<script
language="javascript" type="text/javascript">
  function initDwf()
{
  var strFileName

    "http://SERVER_O

face="Courier New" size=2>R_IP/SomeDir/MyFile.dwf";
  var
strNamedView = "ALL";

  // this is how we call the DWF
to load
   var strUrl = strFileName +

     "\?NotifyMissingFonts=false" +

     "\&NamedView=" +
strNamedView;

 

  // load the
file
   AdView.SourcePath = strUrl;

 

  // set your custom
parameters 
   AdView.width = screen.availWidth -
10;
   AdView.height = screen.availHeight - 10;

 

  // adjust some other
properties


size=2>   AdView.Viewer.ToolbarVisible =
false;
   AdView.Viewer.PaperVisible =
false;
   AdView.Viewer.LinksEnabled =
false;
   AdView.Viewer.BackColor = 0;

 

  // Call some other setup
functions, if desired

     
setTimeout("setupLayersToTurnOn();", 1000);


size=2>      

    return
true;
 }

 function setupLayersToTurnOn()
{

    var
objLayer;
    var strLayersToShow
= "LAYER1,LAYER2,LAYER3";  // turn on whatever layers

 

  // make sure the DWF is loaded
before attempting to access Layers collection
   
AdView.Viewer.WaitForPageLoaded();    
  
  //Put
layers to turn on into an array  
    var
arrLayersToShow = strLayersToShow.split(",");

 

  // Turn all layers
OFF
  var colLayers = AdView.Viewer.Layers;
   
for(var i=1;i<=colLayers.count;i++) {
     
colLayers(i).visible = false;

 

      // Turn
ON only layers those layers you wish to
see
       for(var
j=0;j<arrLayersToShow.length;j++) {
   
     if(colLayers(i).name==arrLayersToShow) {

           
colLayers(i).visible = true;
   
      
break;
       }
    }

face="Courier New" size=2> }
</script>
<object id="AdView"

 classid="clsid:A662DA7E-CCB7-4743-B71A-D817F6D575DF" border="0"

 codebase="

href="http://www.autodesk.com/global/expressviewer/installer/ExpressViewerSetup.cab">
face="Courier...

face="Courier New" size=2>"
>
   <param
name="Src">
</object>

<!--

    Call the setup
function(s) inline like so:

-->
<script
language="javascript"
type="text/javascript">
 initDwf();
</script> 

</body>
</html>

Notice that the
object definition does NOT have a value for the Src parameter.  We set this
when we call the initDwf() function. 


size=2>
 

Now this method
won't work for everything.  For example, if we want to turn on or off
layers programatically at load time, then we'll still have to deal with the
evils of the WaitForPageLoaded() method. 
But, if you use the setTimeout() method, as
shown, the method won't throw an error.  If it throws, then just set the
wait period up from
face="Courier New">1000
.

 

Now, there may be a better way of doing this, and
this assembly of workarounds is certainly not my idea of perfection. 
I do know that this works more often than not.  But, considering
the issues of some of the people in this NG, hopefully this will help out
until then next version of AEV fixes these issues ;).

 

Let me know if this helps anyone out.


face=Arial>
 

😛



size=2>---------------------------------------------------------
Peter B.
Lone
Living Workplace Corporation
(240) 683-6060
FAX: (240)
683-6070
2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: Anonymous

Code Correction:

 

The inner for loop
in the example code I posted is missing a closing bracket for the
face="Courier New">if
statement.  The code should appear like
this:

 


size=2>      // Turn ON only
layers those layers you wish to see
      
for(var j=0;j<arrLayersToShow.length;j++) {
   
     if(colLayers(i).name==arrLayersToShow) {

           
colLayers(i).visible = true;
   
       break;


size=2>         }
       }


😛


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">

All:

 

This is a response to several earlier posts
by "vanceg" and others.  As far as I know, there is no good way to
utilize the WaitForPageLoaded() method of
AdView.Viewer when using it inline, as the
script throws an error.  So here'a a little JavaScript
code that lets you set properties for the
face="Courier New">AdView
object. 

 

The trick is to load an *empty* instance of the
object, and then load the DWF during page load.  This lets us bypass
having to wait an inital DWF load and gives us access to many of the
properties as soon as the empty
face="Courier New">AdView
 instance is loaded.  So a
sample bit of code would look like this:

 


size=2><html>
<head></head>
<body>
<script
language="javascript" type="text/javascript">
  function initDwf()
{
  var strFileName

    "http://SERVER_O

face="Courier New" size=2>R_IP/SomeDir/MyFile.dwf";
  var
strNamedView = "ALL";

  // this is how we call the
DWF to load
   var strUrl = strFileName +

     "\?NotifyMissingFonts=false" +

     "\&NamedView=" +
strNamedView;

 

  // load the
file
   AdView.SourcePath = strUrl;

 

  // set your custom
parameters 
   AdView.width = screen.availWidth -
10;
   AdView.height = screen.availHeight - 10;

 

  // adjust some other
properties


size=2>   AdView.Viewer.ToolbarVisible =
false;
   AdView.Viewer.PaperVisible =
false;
   AdView.Viewer.LinksEnabled =
false;
   AdView.Viewer.BackColor = 0;

 

  // Call some other setup
functions, if desired

     
setTimeout("setupLayersToTurnOn();", 1000);


size=2>      

    return
true;
 }

 function setupLayersToTurnOn()
{

    var
objLayer;
    var strLayersToShow
= "LAYER1,LAYER2,LAYER3";  // turn on whatever layers

 

  // make sure the DWF is loaded
before attempting to access Layers collection
   
AdView.Viewer.WaitForPageLoaded();    
  
  //Put
layers to turn on into an array  
    var
arrLayersToShow = strLayersToShow.split(",");

 

  // Turn all layers
OFF
  var colLayers = AdView.Viewer.Layers;
   
for(var i=1;i<=colLayers.count;i++) {
     
colLayers(i).visible = false;

 

   
  // Turn ON only layers those layers you wish to
see
       for(var
j=0;j<arrLayersToShow.length;j++) {
   
     if(colLayers(i).name==arrLayersToShow) {

           
colLayers(i).visible = true;
   
      
break;
       }
    }

face="Courier New" size=2> }
</script>
<object id="AdView"

 classid="clsid:A662DA7E-CCB7-4743-B71A-D817F6D575DF" border="0"

 codebase="

href="http://www.autodesk.com/global/expressviewer/installer/ExpressViewerSetup.cab">
face="Cou...

face="Courier New" size=2>"
>
   <param
name="Src">
</object>

<!--

    Call the
setup function(s) inline like so:

-->
<script
language="javascript"
type="text/javascript">
 initDwf();
</script> 

</body>
</html>

Notice
that the object definition does NOT have a value for the Src parameter. 
We set this when we call the initDwf()
function. 


size=2>
 

Now this
method won't work for everything.  For example, if we want to turn on or
off layers programatically at load time, then we'll still have to deal with
the evils of the WaitForPageLoaded()
method.  But, if you use the setTimeout()
method, as shown, the method won't throw an error.  If it throws, then
just set the wait period up from
face="Courier New">1000
.

 

Now, there may be a better way of doing this, and
this assembly of workarounds is certainly not my idea of
perfection.  I do know that this works more often than not.  But,
considering the issues of some of the people in this NG, hopefully this
will help out until then next version of AEV fixes these issues
;).

 

Let me know if this helps anyone
out.


face=Arial>
 

😛



size=2>---------------------------------------------------------
Peter B.
Lone
Living Workplace Corporation
(240) 683-6060
FAX: (240)
683-6070
Message 3 of 3
Anonymous
in reply to: Anonymous

Thx for the post, Peter.

I hate using timing loops as do you-they're too machine speed dependent-if you set the delay to work on an old MMX-233, you'll sit waiting an ungodly long time watching the already loaded drawing on a P4-2G!

I'm gonna dig deeper into the Plot options available when creating a .DWF and see if I can't force a default view of the drawing with the paper shown to extent when it's loaded by Express.

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

Post to forums  

Autodesk Design & Make Report