Script sample for getting the selected object in scene

Smart people ~ Great Scripts
Post Reply
ChMar
Petty Officer Second Class
Posts: 33
Joined: 24 Jun 2009, 23:31

Script sample for getting the selected object in scene

Post by ChMar »

Hi. This is my first post and my experience with trueSpace is somehow limited. I try to make an exporter plugin and so far I managed to compile and load a plugin in trueSpace. While Roman philosophy for the workspace is very intriguing and powerful but the SDK is a real pain. It's very nice structured from a design point of view and not that hard to work with. But not all COM return types are considered in trueSpace and sometime trueSpace code dose not correctly check for function return codes. Also the logging support is very rudimentary. This and the fact that SDK documentation is just a Doxygen documentation leaves alot of questions unanswered. A lot of trueSpace functionality is provided to be used in scripting. So even if you use the SDK to make plugins you could still benefit from having good scripting experience. My exporter provides through a script interface the function Export. This function receives 2 string parameters. First is the name of the object and second is the path for file. I want that if the first parameter is void to be able to get the list of selected objects. So please tell me what kind of functions you use to determine the list of current selected objects or for example to get an object using its path like ‘Project/Space 3D/Sphere’.
User avatar
Prodigy
Site Admin
Posts: 957
Joined: 21 May 2009, 14:46
Type the number ten into the box: 0
Location: Uruguay

Re: Script sample for getting the selected object in scene

Post by Prodigy »

Sorry, im not expert on Script or sdk but this is what you are searching?

Code: Select all

System.Alert(Node.Selected(0));
๑۩۞۩๑ prodigy ๑۩۞۩๑
ChMar
Petty Officer Second Class
Posts: 33
Joined: 24 Jun 2009, 23:31

Re: Script sample for getting the selected object in scene

Post by ChMar »

Thank a lot. Yes this works

Code: Select all

Node.Selected(idx)
will select the idx object in a selection or if no object is in selection at that index will fail nicely. And also in Node script interface seams to be

Code: Select all

Node.Select('Project/Space 3D/Cube')
witch will select an object with it's name. Thank so much this is realy the solution in looking for.
User avatar
Prodigy
Site Admin
Posts: 957
Joined: 21 May 2009, 14:46
Type the number ten into the box: 0
Location: Uruguay

Re: Script sample for getting the selected object in scene

Post by Prodigy »

haaa good :bananadrum:

Please, call me Mr. Scriptor :lol:
๑۩۞۩๑ prodigy ๑۩۞۩๑
v3rd3
Lieutenant Commander
Posts: 1177
Joined: 21 May 2009, 20:04

Re: Script sample for getting the selected object in scene

Post by v3rd3 »

CHMar Just to let you know it is there, there is a developer site starting up at http://www.truespaceplugins.com. You will find a few people there that are experienced in both cpp and javascript and who are quite willing to help.
ChMar
Petty Officer Second Class
Posts: 33
Joined: 24 Jun 2009, 23:31

Re: Script sample for getting the selected object in scene

Post by ChMar »

Thanks. I didn't know about trueSpacePlugins. I'lll keep an eye on it. Anyway the ideea of using Node to do the selection parsing didn't work in C++ :(. So time to try something else
stan
Master Chief Petty Officer
Posts: 580
Joined: 21 May 2009, 17:20

Re: Script sample for getting the selected object in scene

Post by stan »

for c++ use RsSelectionHelper.h
your plugin class in the < >.

#include "RsSelectionHelper.h" //selections support

CComBSTR bszObjectName;
if (bszObjectName.Length() < 1)
{ // Default selection:
RsSelectionHelper::GetFirstSelectedNodeName<CRpPlugin>(&bszObjectName);
}

:bananatyping:
ChMar
Petty Officer Second Class
Posts: 33
Joined: 24 Jun 2009, 23:31

Re: Script sample for getting the selected object in scene

Post by ChMar »

Stan thanks a lot. I didn't manage to create the Node aka IRiNodeItem to access the sellected node. Your method is very friendly. Documentation says nothing about the streams in a mesh object. I managed to get the IRdMesh and got the TriangleStreamGroup. Can I assume that all streams in the TriangleStreamGroup will have the same number of entries? ANd if the number of entries differs then should I ignore other streams like IRdUVTriangleStream and use just the IRdTriangleStream?

Thanks
Post Reply