Difference between revisions of "Layerservice"

From The Foundry MODO SDK wiki
Jump to: navigation, search
(Created page with "=Layerservice= Commands are executed and queried directly through the command syntax description previously in this guide, but this doesn’t provide any detailed information ...")
 
m ("Selecting" Layers, Vertex Maps, etc.)
Line 46: Line 46:
  
 
==="Selecting" Layers, Vertex Maps, etc.===
 
==="Selecting" Layers, Vertex Maps, etc.===
As mentioned above, it is important to note that all attributes work only on the current layer chosen for querying. This is especially true of the vert.???, poly.??? and edge.??? element attributes.
+
As mentioned above, it is important to note that all attributes work only on the current layer chosen for querying. This is especially true of the ''vert.???, poly.???'' and ''edge.???'' element attributes.
  
 
This is termed as selection, but is not the same as how you select elements with the mouse through the interface; rather this is to provide layerservice with a context to query another attribute. This kind of selection is performed by simply querying one of the attributes of the element you want to select.
 
This is termed as selection, but is not the same as how you select elements with the mouse through the interface; rather this is to provide layerservice with a context to query another attribute. This kind of selection is performed by simply querying one of the attributes of the element you want to select.
  
For example, to "select" a layer, simply query any layer.??? attribute, such as layer.index.
+
For example, to "select" a layer, simply query any ''layer.???'' attribute, such as layer.index.
 
   query layerservice layer.index ? main
 
   query layerservice layer.index ? main
  
After this, the various vert.???, poly.???, etc. attributes can be used. The return value from the query above can be ignored; our only purpose is to tell layerservice which layer we plan to query the properties of.
+
After this, the various ''vert.???, poly.???'', etc. attributes can be used. The return value from the query above can be ignored; our only purpose is to tell layerservice which layer we plan to query the properties of.
  
Once "selected", it remains until a new call to one of the layer.??? attributes.
+
Once "selected", it remains until a new call to one of the ''layer.???'' attributes.
  
 
Similarly, attributes such as vert.vmapValue and poly.vmapValue require a vertex map selection, as mentioned in the attribute’s description
 
Similarly, attributes such as vert.vmapValue and poly.vmapValue require a vertex map selection, as mentioned in the attribute’s description

Revision as of 09:21, 31 January 2014

Layerservice

Commands are executed and queried directly through the command syntax description previously in this guide, but this doesn’t provide any detailed information about meshes and their related elements.

The layerservice ScriptQuery can be used to obtain this detailed mesh information.

Many item-level operations in layerservice have been superseded by those in Sceneservice. Be sure to check Sceneservice to see if it is more appropriate to your task than layerservice. In general, when you want to deal with items and their channels or when you want scene-level information, you'll mostly be making use of sceneservice. When you want to deal with modeling operations or need to obtain information about the specific vertices, polygons and edges of a mesh, you'd use layerservice.

Due to its design, layerservice is only meant to work on mesh items. Attempting to pass other kinds of items to any of the attributes will fail.

Special Selectors

This interface hosts a series of global lists of layers, models, materials, parts, textures, clips and vertex maps. There are also local lists specific to the layer selection for accessing vertices, edges and polygons.

The root-level attributes ending in an ‘s’ all return valid selectors for the more specific property attributes, similar to how the return values from the Commandservice commands and Categories attributes are the selectors for the more specific property attributes. However, the layerservice ‘s’ attributes require the use of selectors returned by the various attributes ending in _groups to filter the query to specific groups of elements.

The ‘s’ attributes are layers, kids, materials, parts, textures, clips, vmaps, verts, polys, edges and models.

The _groups attributes are layer_groups, kid_groups, material_groups, part_groups, texture_groups, clip_groups, vmap_groups, vert_groups, poly_groups and edge_groups.

Using Selectors

In the case of layers, the _groups attribute returns the keywords main, fg, bg and all. Getting a list of foreground layers is done in the following example.

query layerservice layers ? fg

Each of the values returned by this query can be passed into the a more specific property attribute, such as layer.subdivLevel. In the following example we assume that the query returned "0", and we provided that as the selector to layer.subdivLevel:

query layerservice layers.subdivLevel ? 0

Alternatively, all of the different ‘s’ attributes support the list walking keywords returned by the layers_element attributes first, last, next and prev, which are fairly self-explanatory. This example returns the first vertex map:

query layerservice vmaps ? first

The result of this query can then be passed to the property attributes. The next vertex map can then be obtained with:

query layerservice vmaps ? next

And so on.

Layer-Specific Selections

In the case of vertices, edges and polygons, a layer selection is required before any of their attributes can be used. This can be done by using any of the layer attributes that takes a selection.

The layer.index attribute, for example, actually gets the index of a specific layer, but it also changes the selection in the service.

In this example we switch the layer selection to the primary layer, discarding the returned value:

query layerservice layer.index ? main

After that, the various vertex, polygon and edge attributes can be used to get information specifically related to that layer, such as this query to get the number of selected vertices in the layer:

 query layerservice vert.N ? selected

The above example also demonstrates the different grouping keywords used by the local lists. A complete list of keywords can be obtained by querying vert_groups, edge_groups and poly_groups, and includes selected, unselected, and all.

"Selecting" Layers, Vertex Maps, etc.

As mentioned above, it is important to note that all attributes work only on the current layer chosen for querying. This is especially true of the vert.???, poly.??? and edge.??? element attributes.

This is termed as selection, but is not the same as how you select elements with the mouse through the interface; rather this is to provide layerservice with a context to query another attribute. This kind of selection is performed by simply querying one of the attributes of the element you want to select.

For example, to "select" a layer, simply query any layer.??? attribute, such as layer.index.

 query layerservice layer.index ? main

After this, the various vert.???, poly.???, etc. attributes can be used. The return value from the query above can be ignored; our only purpose is to tell layerservice which layer we plan to query the properties of.

Once "selected", it remains until a new call to one of the layer.??? attributes.

Similarly, attributes such as vert.vmapValue and poly.vmapValue require a vertex map selection, as mentioned in the attribute’s description

Selecting Points, Polygons and Edges

The select.element command can be used to select vertices, polygons and edges (this is selecting like how you would select a polygon in a model viewport, not the query selecting described in the previous section).

Once selected, elements can be manipulated using other commands. In all cases, the selectors returned by the verts, polys and edges attributes can be used to select those individual elements. verts and polys bother return element indices, while edges returns a vertex pair separated by commas and wrapped in parentheses, such as "(21, 18)".

layers

  • layer_groups
  • layer_lists
  • layer_elements
  • layer
  • layer.N
  • layer.name
  • layer.index
  • layer.subdivLevel
  • layer.splPatchLevel
  • layer.curveAngle
  • layer.parent
  • layer.childCount
  • layer.children
  • layer.pivot
  • layer.bounds
  • layer.visible
  • layer.model
  • layer.id
  • layer.wpos
  • layer.wbounds

kids

  • kid
  • kid_groups
  • kid.N
  • kid.name
  • kid.index
  • kid.layer
  • kid.parent

parts

  • part
  • part_groups
  • part.N
  • part.name
  • part.index
  • part.layer

models

  • model
  • model_groups
  • model.N
  • model.name
  • model.index
  • model.layer
  • model.curName
  • model.curIndex
  • model.file

materials

  • material
  • material_groups
  • material.N
  • material.name
  • material.index
  • material.layer
  • material.opacity
  • material.color
  • material.luminous
  • material.diffuse
  • material.specular
  • material.gloss
  • material.reflect
  • material.transp
  • material.transl
  • material.refIndex
  • material.bump
  • material.colHigh
  • material.colFilt
  • material.difSharp
  • material.id
  • material.textures

textures

  • texture
  • texture_groups
  • texture.N
  • texture.name
  • texture.index
  • texture.layer
  • texture.id
  • texture.type
  • texture.channel
  • texture.opacity
  • texture.enable
  • texture.invert
  • texture.blendMode
  • texture.position
  • texture.rotation
  • texture.scale
  • texture.projType
  • texture.projAxis
  • texture.coordSys
  • texture.fallType
  • texture.falloff
  • texture.uvName
  • texture.uvMap
  • texture.clip
  • texture.clipFile
  • texture.locator

clips

  • clip
  • clip_groups
  • clip.N
  • clip.name
  • clip.index
  • clip.layer
  • clip.file
  • clip.id
  • clip.info

vmaps

  • vmap
  • vmap_groups
  • vmap.N
  • vmap.name
  • vmap.index
  • vmap.layer
  • vmap.type
  • vmap.dim
  • vmap.selected
  • vmap.tag

verts

  • vert
  • vert_groups
  • vert.N
  • vert.name
  • vert.index
  • vert.layer
  • vert.pos
  • vert.normal
  • vert.numPolys
  • vert.polyList
  • vert.numVerts
  • vert.vertList
  • vert.vmapValue
  • vert.selected
  • vert.hidden
  • vert.selSets
  • vert.symmetric
  • vert.wpos
  • vert.workpos
  • vert.defpos
  • vert.wdefpos

polys

  • poly
  • poly_groups
  • poly.N
  • poly.name
  • poly.index
  • poly.layer
  • poly.numVerts
  • poly.vertList
  • poly.normal
  • poly.type
  • poly.vmapValue
  • poly.discos
  • poly.material
  • poly.part
  • poly.selected
  • poly.hidden
  • poly.pos
  • poly.tags
  • poly.tagTypes
  • poly.selSets
  • poly.symmetric
  • poly.wpos
  • poly.wnormal
  • poly.vertNormals
  • poly.wvertNormals
  • poly.workpos
  • poly.worknormal

edges

  • edge
  • edge_groups
  • edge.N
  • edge.name
  • edge.index
  • edge.layer
  • edge.vertList
  • edge.numPolys
  • edge.polyList
  • edge.length
  • edge.creaseWeight
  • edge.vector
  • edge.pos
  • edge.selected
  • edge.hidden
  • edge.selSets
  • edge.symmetric
  • edge.wpos
  • edge.wvector
  • edge.workpos
  • edge.workvector

uvs

  • uv
  • uv_groups
  • uv.N
  • uv.name
  • uv.index
  • uv.layer
  • uv.vert
  • uv.poly
  • uv.vmap
  • uv.disco
  • uv.pos
  • uv.selected
  • uv.hidden

polsets

  • polset
  • polset_groups
  • polset.N
  • polset.name
  • polset.index
  • polset.layer

vrtsets

  • vrtset
  • vrtset_groups
  • vrtset.N
  • vrtset.name
  • vrtset.index
  • vrtset.layer

itmsets

  • itmset
  • itmset_groups
  • itmset.N
  • itmset.name
  • itmset.index
  • itmset.layer

selection

selmode