Viewpoint Developer Central    Viewpoint Forums    Viewpoint Forums  Hop To Forum Categories  JavaScript    accessing MTSGeometry vertices from javascript via getproperty

Moderators: e_phoenix13
Go
New
Find
Notify
Tools
Reply
  
-star Rating Rate It!  Login/Join 
Member
Posted
Is there a way to access an object geometry vertices using the getproperty function from javascript. tried the following it does not work
var pos = vmp.GetProperty("MTSGeometry.bx.MSTGeometry", "Vertices");

alert(pos);

hope somebody can help

ps. can we set the vertice value?
 
Posts: 6 | Registered: June 15, 2006Reply With QuoteEdit or Delete MessageReport This Post
Member
Picture of Admin
Posted Hide Post
Try this way:

var pos = vmp.GetProperty("MTSGeometry.myGeometryName", "Vertices[0]", "mts_pnt3d");

That will get the x,y,z values of the vertex at index 0. (you can also have the whole array returned to you by not specifying an index number). To set a vertex value:

vmp.SetProperty("MTSGeometry.myGeometryName", "Vertices[0]", "pos", "mts_pnt3d");

For more info on the Vertices array, refer to the XML database and search for "vertices".

Here's another post on the topic that might help. I would also recommend doing a search in the Forums for keyword "vertices".

Regards

This message has been edited. Last edited by: Admin,
 
Posts: 1188 | Registered: January 08, 2003Reply With QuoteEdit or Delete MessageReport This Post
Junior Member
Posted Hide Post
Admin,
you say that you can access the whole array of Vertices by not specifying the index number, but how do you do it?

I tried:

var pos = vmp.GetProperty("MTSGeometry.myGeometryName", "Vertices[]", "mts_pnt3d");

but it doesn't work. what should the type be? "mts_array" or something like that.

I also tried the following from the mtx file

MTSInstance.objectName.MTSGeometry.Vertices
MTSInstance.objectName.MTSGeometry::Vertices
MTSGeometry.geometryName.vertices
MTSGeometry.geometryName::vertices

Nothing works. I can only get the individual vertex with Vertices[x].

Please help
 
Posts: 3 | Registered: March 30, 2007Reply With QuoteEdit or Delete MessageReport This Post
Member
Picture of Admin
Posted Hide Post
The only thing you’ll ever get from get property from the html is a string… you’ll have to convert it to the type of object you need. So if you ask for a pnt3d, you’re going to get a string like “x y z”, and you’ll have to do pos.split(“ “) to get the values.

Quite honestly I don’t know if you can get all the verticies at once from the html using getproperty, there may not be a type that would accommodate it, maybe mts_str?

From the mtx and via VETScript you should be able to get the entire vertices array of an object using dot syntax:

verts = MTSGeometry.geometryname.Vertices;

Vertices is an array of objects of type Point3D, so the assignment creates a reference to the array, and you would access the points properties like so:

verts[i].x

verts[i].y

verts[i].z
 
Posts: 1188 | Registered: January 08, 2003Reply With QuoteEdit or Delete MessageReport This Post
  Powered by Eve Community  
 

Viewpoint Developer Central    Viewpoint Forums    Viewpoint Forums  Hop To Forum Categories  JavaScript    accessing MTSGeometry vertices from javascript via getproperty