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

javascript to set layers

8 REPLIES 8
Reply
Message 1 of 9
Anonymous
378 Views, 8 Replies

javascript to set layers

Is there any way to allow layer manipulation after the DWF file is loaded. There does not seem to be any visible means to do this? Are there any undocumented or hidden parameters to accomplish this? Is there any way to do this with javascript?

--Getting Frustrated with express viewer
8 REPLIES 8
Message 2 of 9
Anonymous
in reply to: Anonymous

Here's how to do it with VBScript

 

 
'-------------------------------------------------------------------'
 
' This demonstrates using the layers collection via an enumerator  
'
 
'-------------------------------------------------------------------'
 
function ShowLayers
    dim layer

 

    ' Make sure the page is fully
loaded first
    call
AdView.Viewer.WaitForPageLoaded()

 

    ' Turn all the layers
off
    for each layer in
AdView.Viewer.Layers
      layer.Visible =
false
    next

 

    ' Display each layer by
itself
    for each layer in
AdView.Viewer.Layers
      layer.Visible =
true
      MsgBox
layer.name
      layer.Visible =
false
    next

 

    ' Turn all the layers back
on
    for each layer in
AdView.Viewer.Layers
      layer.Visible =
true
    next
  end function


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Is
there any way to allow layer manipulation after the DWF file is loaded. There
does not seem to be any visible means to do this? Are there any undocumented
or hidden parameters to accomplish this? Is there any way to do this with
javascript?

--Getting Frustrated with express viewer

Message 3 of 9
Anonymous
in reply to: Anonymous

Thank You Peter,
I did finally find this format. I still have a problem finding out how to set certain layers on and off.

For example your cod steps in and turns all layers off then gets the first layer and turns it on and then loops.

What I need to find out is to how to have maybe an array store all the layers, and then be able to turn on/off layers by an index, or have "for each layer in adview.viewer.layer" call another function that defines an array of predefined values for all layers and then based off of the match, set just a single layer to false?

In whip, we could use "FindNextLayer()"

any ideas???

Appreciate all your help.

Scott
Message 4 of 9
Anonymous
in reply to: Anonymous

tell me about it! Have you been able to get it to show a .dwf within Netscape using the express viewer as a plugin??
Reference my question recently posted about Netscape compatibility?

Good luck to you.
Message 5 of 9
Anonymous
in reply to: Anonymous

Layers are stored in a collection and can be
accessed either by name or by index, for example:

 

--

 
function TurnOffLayer
    dim layer

 

    ' Make sure the page is fully
loaded first
    call
AdView.Viewer.WaitForPageLoaded()


    Set layer =
AdView.Viewer.Layers.Item("LayerName")
    layer.visible =
false

 

  end function


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Thank
You Peter,
 I did finally find this format. I still have a problem
finding out how to set certain layers on and off.

For example your cod steps in and turns all layers off then gets the first
layer and turns it on and then loops.

What I need to find out is to how to have maybe an array store all the
layers, and then be able to turn on/off layers by an index, or have "for each
layer in adview.viewer.layer" call another function that defines an array of
predefined values for all layers and then based off of the match, set just a
single layer to false?

In whip, we could use "FindNextLayer()"

any ideas???

Appreciate all your help.

Scott

Message 6 of 9
Anonymous
in reply to: Anonymous


The Layers property is a
collection with properties Item, Count and ItemName. The following Java Script
should do what you are looking for.


 



size=2>function LayerTwoOff ()



size=2>{



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



size=2> 



size=2>  if (
AdView.Viewer.Layers.Count >=2 )



size=2>
style="mso-spacerun: yes">  
{



size=2>   
AdView.Viewer.Layers.Item(2).Visible =
false;



size=2>
style="mso-spacerun: yes">  
}



size=2>}



style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Thank
You Peter,
 I did finally find this format. I still have a problem
finding out how to set certain layers on and off.

For example your cod steps in and turns all layers off then gets the first
layer and turns it on and then loops.

What I need to find out is to how to have maybe an array store all the
layers, and then be able to turn on/off layers by an index, or have "for each
layer in adview.viewer.layer" call another function that defines an array of
predefined values for all layers and then based off of the match, set just a
single layer to false?

In whip, we could use "FindNextLayer()"

any ideas???

Appreciate all your help.

Scott

Message 7 of 9
Anonymous
in reply to: Anonymous

Try this:

 


 function setupLayersToTurnOn()
{

 

  // make sure the DWF is loaded
before attempting to access Layers collection
   
AdView.Viewer.WaitForPageLoaded();    

face="Courier New" size=2>

  //Put layers to turn on into an
array  
    // Method 1: assign to string and
split into array

        var strLayersToShow
= "LAYER1,LAYER2,LAYER3";  

        var arrLayersToShow =
strLayersToShow.split(",");

 

    // Method 2: assign
to array directly

       
// var arrLayersToShow = new Array("LAYER1", "LAYER2", "LAYER3");

 

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

 

      // Only
yurn ON 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">         }

       }
    }

face="Courier New" size=2> }

HTH,

 

😛


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Thank
You Peter,
 I did finally find this format. I still have a problem
finding out how to set certain layers on and off.

For example your cod steps in and turns all layers off then gets the first
layer and turns it on and then loops.

What I need to find out is to how to have maybe an array store all the
layers, and then be able to turn on/off layers by an index, or have "for each
layer in adview.viewer.layer" call another function that defines an array of
predefined values for all layers and then based off of the match, set just a
single layer to false?

In whip, we could use "FindNextLayer()"

any ideas???

Appreciate all your help.

Scott

Message 8 of 9
Anonymous
in reply to: Anonymous

Thank you both Peter and Ben,
This is exactly what I was looking for.
--Scott
Message 9 of 9
Anonymous
in reply to: Anonymous

Peter Lone,
This is also great Thank you all!!!!!!

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

Post to forums  

Autodesk Design & Make Report