%%PageItemTitle%%

VectorDraw Web Library

JsPropertiesExtractor Send comments on this topic.
GetXProperty Method
See Also  Example
vdWebLibrary Namespace > vdrawObj Class : GetXProperty Method
entity
The entity from which the XProperty is to be taken.
name
The name of the XProperty to be found.
Returns the first XProperty by the given name to be found in the passed entity. Null if none is found.

Syntax

JScript 
public function GetXProperty( 
   entity : Object,
   name : String
) : Object;

Parameters

entity
The entity from which the XProperty is to be taken.
name
The name of the XProperty to be found.

Return Value

The first XProperty found or null.

Example

Here is an example where we search in mousedown event for a specific XProperty of an entity and if we find it we change it’s value,if not we add a new one.
C#Copy Code
  
function _vdmousedown(e) { 
   var entity = e.target.GetEntityFromPoint(e.xPix, e.yPix); 
   if (entity.XProperties === undefined) {// in case there are not any XProperties we add the new that I want 
       var newExProp = vdcanvas.AddXProperty(entity, 'name1', 5.0); 
   } 
   else { 
       for (var i = 0; i < entity.XProperties.Items.length; i++) {//search for the XProperty we want by it’s name 
           if (entity.XProperties.Items[i].Name == "name1") { 
               var xprop = vdcanvas.GetXProperty(entity, "name1");//If we find the XProperty name that we search for, we change its value  
               xprop.PropValue = 'newValue';                      
           } 
           else { 
               if (newExProp) return; 
               var newExProp = vdcanvas.AddXProperty(entity, 'name1', 5.0); // if we didn’t find the Xproperty that we were searching for in the XProperties of the entity,we add a new one                       
           } 
       } 
   } 
}

See Also