PDA

View Full Version : layerMesh object index



kungfuzius
01-08-2008, 05:21 AM
Hey there,

I want to create a meshinfo of the currently selected object, but "selItems" only gives me back object IDs, while layerMesh needs an "object index" and "layer index", object index obviously seems not to be the same as object ID. (layer index is not important yet, for my problem i can asume the mesh is in layer 0). I searched all the sdk docs and this forum for hours but didnt come up with a solution. can anyone help me, at least point me in the right direction?

greetings.

Sensei
01-08-2008, 06:34 AM
Comparing objects by names is only way..

kungfuzius
01-08-2008, 06:41 AM
i read so before but which function gives me back the OBJECT INDEX by name?

Sensei
01-08-2008, 12:25 PM
index++? ;) I don't know how easier I could say that technique.. You have list of objects, get 1st one, compare name, if valid break, if not go to next..

kungfuzius
01-08-2008, 12:41 PM
hm didnt know they are sorted (the same way). if that works, fine :thumbsup:

Sensei
01-08-2008, 12:48 PM
They are not sorted AFAIK..

kungfuzius
01-08-2008, 01:21 PM
i meant if the object list, i should compare with, is enumerated the same way as the object_index of layerMesh

kungfuzius
01-10-2008, 05:06 AM
worked... thanks guys :thumbsup:

kungfuzius
01-14-2008, 07:29 AM
there I go again...
it SEEMED to work, but actually didnt.
objname = query->object() always returns me as object filename "CompositeLayerObject", for every object. the weird thing is, objfilename = objfunc->filename(index) does the same. furthermore I now have the problem, that my meshinfo seems to live on after the plugin has ended, even so I destroy it. can that be??

Sensei
01-14-2008, 07:42 AM
Did you properly free LWMeshInfo?

kungfuzius
01-14-2008, 07:48 AM
meshinfo->destroy(meshinfo);

Sensei
01-14-2008, 08:32 AM
if( meshinfo->destroy != NULL )
{
meshinfo->destroy( meshinfo );
}

statequery->object() return reference object name.. See docs:

Returns the filename of the current object. If the geometry in the current layers hasn't been saved to a file yet, this returns the reference name (the name that would be returned by the Object Functions refName function). If no object has been loaded into Modeler, this returns NULL.

kungfuzius
01-14-2008, 08:48 AM
i tried refName, didnt work out at all. query still returns "CompositeLayerObject" while refName returned something like "R3". I ask myself where the 1. thing comes from, the refname seems right, but that "CompositeLayerObject"?

btw Im working in Layout all the time!

kungfuzius
01-18-2008, 03:47 AM
so we came up with this:

intinfo = global( LWINTERFACEINFO_GLOBAL, GFUSE_TRANSIENT );
lwItem = intinfo->selItems;
liFunc = global( LWLISTINFO_GLOBAL, GFUSE_TRANSIENT );
lwItem_dummy = lwItem[0];

active_object_index = liFunc->index(lwItem_dummy);
^^^ but layout crashes ALL THE TIME when it comes to this line of code.
could anybody please tell me whats wrong there? or better, how to make it right 8~

Sensei
01-18-2008, 03:53 AM
You know that you're writing Layout only plug-in, right? Interface Info and List Info are only available in Layout, not in Modeler.. You would know it if you would check whether their globals are not NULL, which seems to be missing in your pseudo code..

kungfuzius
01-18-2008, 04:01 AM
btw Im working in Layout all the time!
...?

Sensei
01-18-2008, 04:02 AM
In that case check whether globals are not NULL. List Info was added in LW v9.3 (more likely) or LW v9.2..

adamredwoods
01-18-2008, 12:54 PM
ALWAYS check if your globals are null and if your first object is a null.

Sometimes when you run LW it selects nothing and your plugin might run as well.



intinfo = global( LWINTERFACEINFO_GLOBAL, GFUSE_TRANSIENT );
liFunc = global( LWLISTINFO_GLOBAL, GFUSE_TRANSIENT );

if( !intinfo || !liFunc) return AFUNC_BADGLOBAL;

lwItem = intinfo->selItems;
lwItem_dummy = lwItem[0];

if(lwItem[0]) active_object_index = liFunc->index(lwItem_dummy);


Disclaimer: I haven't gone over this with any accuracy, so your code could still have problems.