Page 1 of 2 12 LastLast
Results 1 to 15 of 17

Thread: get layer number of selected object?

  1. #1
    Super Member vashts's Avatar
    Join Date
    Jul 2003
    Location
    Tornavento, Italy
    Posts
    365

    get layer number of selected object?

    how can I get the number of the selected layer?
    I've something like this (layout):

    currentElement = scene.firstSelect();

    I can save for example the name of selection (currentElement.name), or its id (currentElement.id), or discover if it's a null (currentElement.null), but how about layer number?

    vashts
    My website: Geba.it
    LightWave Italian Community: LWITA.com

  2. #2
    Member
    Join Date
    May 2006
    Location
    France
    Posts
    4,171
    May be a loop with a counter (not tested)

    currentElement = scene.firstSelect();
    counter = 0;

    while(currentElement)
    {
    counter +=1;
    info(currentElement.name);
    currentElement = scene.nextSelect();
    }

    Denis.

  3. #3
    TrueArt Support
    Join Date
    Feb 2003
    Location
    Poland
    Posts
    8,067
    In LW SDK and C/C++ the only way to check which layer is item is parsing name.. File name are the same, but name has appendix :Layer[number].. I would be surprised whether LScript has it given on plate, if LW SDK doesn't have it..
    Last edited by Sensei; 02-08-2007 at 01:43 PM.

  4. #4
    Worms no more! Free fun! Dodgy's Avatar
    Join Date
    Feb 2003
    Location
    Sydney
    Posts
    8,282
    Funnily enough I put in a feature request today for a command to get the layer info from a file, but we could also do with it for objects already loaded since it's actually quite hard to get the layer number of the current item, if at all possible, either in lscript or the sdk.
    Push the software, don't let it push YOU!
    My own plugins and work:www.mikegreen.name
    LaptopSetup:corei7 2.4GHz nvidia GT 650M 8Gig win8 64
    WorkSetup:core i7 3.4Ghz nvidia Quadro 2000 12Gig Ram Win7

  5. #5
    Member
    Join Date
    May 2006
    Location
    France
    Posts
    4,171
    Oh, yes sorry for mistake,
    something like :
    tokens = parse(":",currentElement.name);
    tokens[2] = ...

    Denis.

  6. #6
    Member
    Join Date
    May 2006
    Location
    France
    Posts
    4,171
    or another counter,
    if (tokens[1] = objectname)
    counter +=1;

    Denis.

  7. #7
    Super Member vashts's Avatar
    Join Date
    Jul 2003
    Location
    Tornavento, Italy
    Posts
    365
    ok, but this isn't a solution; infact, if you rename a layer in modeler, when loaded in layout you haven't the name structure as "objectName:Layer1" but "objectName:LayerName"..

    vashts
    Last edited by vashts; 02-08-2007 at 04:11 PM.
    My website: Geba.it
    LightWave Italian Community: LWITA.com

  8. #8
    TrueArt Support
    Join Date
    Feb 2003
    Location
    Poland
    Posts
    8,067
    LightWave v9.2 LWS file format enhancement will open new way to get object's layer index - save temporary LWS in v9.2 format, parse all rows checking whether it's LoadObjectLayer and it'll have arguments: LWItemID, layer index and LWO file name..

    vashts, you must answer yourself "what for I need layer index".. LightWave's treats LWO like object's catalog with common surface list.. Every layer can live it's own life, moving, rotation and transforming independently from other layers..

    Counting elements in scene without checking name also won't work- try loading layer 2, then layer 1.. They will be in the list in loaded order, not sorted..

  9. #9
    Member
    Join Date
    May 2006
    Location
    France
    Posts
    4,171
    Sure, an internal index, which can be removed,
    for each object layer could be an improvement to manage them.
    But I have a question, why removing the default layer index,
    if you need it?
    There are a lot of tasks, with
    or without Lscript which requires such conditions or rules.
    i.e : A lot of effects need generic names with suffix or prefix.


    Denis.

  10. #10
    Super Member vashts's Avatar
    Join Date
    Jul 2003
    Location
    Tornavento, Italy
    Posts
    365
    Quote Originally Posted by Sensei
    vashts, you must answer yourself "what for I need layer index".. LightWave's treats LWO like object's catalog with common surface list.. Every layer can live it's own life, moving, rotation and transforming independently from other layers..
    I need layer number for the .position() method that, without parameters, returns extreme points of bbox of an object; if you want the same info about the selected layer for example, you need the layer number, otherwise the function returns the bbox of entire object, even you've selected only a layer.

    Quote Originally Posted by dpont
    But I have a question, why removing the default layer index,
    if you need it?
    is the question for me? in modeler you can rename layers name, so in layout you can have object layers without the defalut ":layerX" suffix..

    vashts
    My website: Geba.it
    LightWave Italian Community: LWITA.com

  11. #11
    Member
    Join Date
    May 2006
    Location
    France
    Posts
    4,171
    Ok, for using the .position() method the layer integer is
    required for bbox, I understand what you mean,
    then if you lost default modeler layer name, you can't
    parse the name, and if you load only one renamed layer object
    you can't do a loop for counting and get the integer.

    In this case, except feature request and if your mesh isn't
    too big, you could scan your geometry to get min/max
    position yourself.

    Denis.

  12. #12
    Member
    Join Date
    May 2006
    Location
    France
    Posts
    4,171
    ...But I guess you will need also this layer integer for that...

    Denis.

  13. #13
    Member
    Join Date
    May 2006
    Location
    France
    Posts
    4,171
    Sorry Edit failed:
    There's a layer() method to get the layer integer
    for a point identifier (Id) so you can scan a
    specific layer by its number, but you should be
    sure this point is loaded in Layout !?

    Denis.
    Last edited by dpont; 02-11-2007 at 09:33 AM.

  14. #14
    Member
    Join Date
    May 2006
    Location
    France
    Posts
    4,171
    Last thing, but more complicated for your Lscript,
    the layer integer is saved in the scene before the
    object name, but your scene is not necessary saved;
    and parsing it is tedious!

    Denis.

  15. #15
    Super Member vashts's Avatar
    Join Date
    Jul 2003
    Location
    Tornavento, Italy
    Posts
    365
    thankyou denis. so much complicated for a so simple feature.. uff..

    vashts
    My website: Geba.it
    LightWave Italian Community: LWITA.com

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •