Page 5 of 5 FirstFirst ... 345
Results 61 to 72 of 72

Thread: Lscript Question

  1. #61
    Super Member Kryslin's Avatar
    Join Date
    Feb 2009
    Location
    Prescott, IA
    Posts
    1,306
    Ok, another question...

    Both selPoint() and selPolygon() have a minor parameter of POINTNDX and POLYNDX, respectively.

    What is this? What array am I supplying indices to the selection command? Is this global, or relative to the selection I may be working with? I'm more curious than anything...

    I mean, I get POINTID and POLYID, and I normally use these all the time, inside an editbegin() and editend() pair. So what are these poly and point indices?
    --------
    Intel Core i7 960 @3.20 Ghz, 24 GB ram, EVGA 6GB GTX980Ti "Classified" driving 2 x HP LA2405.

  2. #62
    I believe is it the id of the point/polygon. I would assume it's global to the model since ids don't change dynamically.
    My opinions and comments do not represent those of my employer.
    www.ernestpchan.com
    www.zazzle.com/gopuggo

  3. #63
    TrueArt Support
    Join Date
    Feb 2003
    Location
    Poland
    Posts
    7,643
    Points can be identified by index (starting from 0..point_count-1) or by LWPntID pointer.
    Polygons can be identified by index (starting from 0...poly_count-1) or by LWPolID pointer.
    If you have address (i.e. outside of 0..count-1) it's the second one.
    LightWave Plugins
    Global Materials for LightWave 2018!
    Custom plugin writing. Request a quote.

  4. #64
    Valiant NewTeKnight Matt's Avatar
    Join Date
    Feb 2003
    Location
    San Antonio, Texas, USA
    Posts
    13,050

    Post

    This is not an exhaustive list, but this is a scratch pad of some poly / point stuff (it's not a script you can run as is, just a collection of stuff) that I kept lying around, might help.

    Code:
    @version 2.13
    @warnings
    @name "Point and Polygon Routines"
    
    main
    {
        // Selected including nothing selected = all selected rule
        selmode( USER );
    
        // Direct selections only
        selmode(DIRECT);
    
        // Selected everything regardless of selection
        selmode( GLOBAL );
    
        // 0 = Point / 1 = Poly / 2 = Volume / 3 = Edge
        selection_mode = getmode("SELECTION");
    
        // 0 = Off / 1 = On
        symmetry_mode = getmode("SYMMETRY");
    
        // 0 = Mouse / 1 = Pivot / 2 = Selection / 3 = Pivot
        action_center_mode = getmode("ACTIONCENTER");
    
        // Get the point count
        point_count = pointcount();
    
        // Need minimum of two points
        if(point_count < 2)
        {
            error("You need to select at least 2 points");
        }
    
        // Get selected poly information
        selectedPolys = polycount();
    
        // Total number of selected polygons
        selectedTotalPolys = selectedPolys[1];
    
        // Total number of selected polygons with 1 point
        selected1PointPolys = selectedPolys[2];
    
        // Total number of selected polygons with 2 points
        selected2PointPolys = selectedPolys[3];
    
        // Total number of selected polygons with 3 points
        selected3PointPolys = selectedPolys[4];
    
        // Total number of selected polygons with 4 points
        selected4PointPolys = selectedPolys[5];
    
        // Total number of selected polygons more than 4 points
        selectedMoreThan4PointPolys = selectedPolys[6];
    
    
    
        // Storing polygon information
        var polyIDs         = nil;
        var polyTypes       = nil;
        var polyPartTags    = nil;
    
        editbegin();
        foreach(poly, polygons)
        {
            polyIDs         += poly;
            polyTypes       += poly.type();
            polyPartTags    += poly.tag("PART");
        }
        editend();
    
    
    @script modeler
    @warnings
    @name "Part Name"
    
    main
    {
        selmode(DIRECT);
        selectedItems = polycount();
    
        if(selectedItems[1] == 0)
        {
            error("Nothing Selected");
        }
    
        editbegin();
            for(loop = 1; loop <= selectedItems[1]; loop++)
            {
                partName = polygons[loop].tag("PART");
    
                info("Part Name: ", partName);
            }
        editend();
    }
    
    
        // Inspecting polygon information
        var polyNumber = 1;
    
        editbegin();
        // Get ID of polygon
        polyID              = polygons[polyNumber];
    
        // Number of points that make up the poly
        numPointsInPoly     = polypointcount( polygons[polyNumber] );
    
        // The vector for the poly normal
        polyNormal          = polynormal( polygons[polyNumber] );
    
        // Get the surface assigned to the poly
        polyInformation     = polyinfo( polygons[polyNumber] );
        polySurface         = polyInformation[1];
    
        // Store point IDs and positions for polygon
        // Starts at 2 because the surface name is the first entry in the array that polyinfo() returns
        // Every entry in the array after that is the point ID
        for(loop = 2; loop <= numPointsInPoly; loop++)
        {
            polyPointIDArray    += polyInformation[loop];
    
            // Point into gets the points XYZ location
            polyPointPosArray   += pointinfo(polyInformation[loop]);
        }
    
        editend();
    
    
    
        // Selecting and deselecting poly selections
    
        // Select a poly by its ID
        selpolygon( SET, POLYID, polyIDs[1] );
    
        // Select all polys by their ID using a custom function
        select_poly_ids( polyIDs );
    
        // Select all polys
        selpolygon( SET );
    
        // Deselect a poly by its ID
        selpolygon( CLEAR, POLYID, polyIDs[1] );
    
        // Deselect all polys by their ID using a custom function
        deselect_poly_ids( polyIDs );
    
        // Clear all polys
        selpolygon( CLEAR );
    
        // Invert selections
        selinvert();
    
        // Hiding selected polys
        selhide( SELECTED  );
    
        // Hiding unselected polys
        selhide( UNSELECTED  );
    
        // Unhiding hidden polys
        selunhide();
    
    
    
        // Selecting and deselecting point selections
    
        // Select a point by its ID
        selpoint( SET, POLYID, polyPointIDArray[1] );
    
        // Select all points by their ID using a custom function
        select_point_ids( polyPointIDArray );
    
        // Select all points
        selpoint( SET );
    
        // Deselect a point by its ID
        selpoint( CLEAR, POINTID, polyPointIDArray[1] );
    
        // Deselect all points by their ID using a custom function
        deselect_point_ids( polyPointIDArray );
    
        // Clear all points
        selpoint( CLEAR );
    }
    
    select_poly_ids: polyIDArray
    {
        for(loop = 1; loop <= polyIDArray.size(); loop++)
        {
            selpolygon( SET, POLYID, polyIDArray[loop] );
        }
    }
    
    deselect_poly_ids: polyIDArray
    {
        for(loop = 1; loop <= polyIDArray.size(); loop++)
        {
            selpolygon( CLEAR, POLYID, polyIDArray[loop] );
        }
    }
    
    select_point_ids: pointIDArray
    {
        for(loop = 1; loop <= pointIDArray.size(); loop++)
        {
            selpoint( SET, POINTID, pointIDArray[loop] );
        }
    }
    
    deselect_point_ids: pointIDArray
    {
        for(loop = 1; loop <= pointIDArray.size(); loop++)
        {
            selpoint( CLEAR, POINTID, pointIDArray[loop] );
        }
    }
    UI Designer @ NewTek
    __________________________________________________
    www.pixsim.co.uk : LightWave Video Tutorials & Tools


  5. #65
    Super Member Kryslin's Avatar
    Join Date
    Feb 2009
    Location
    Prescott, IA
    Posts
    1,306
    Matt: handy stuff, that.

    Re: getmode("SYMMETRY"); ... is there an equivalent to set / toggle the symmetry mode?

    Still, regards to the indices question... where are those indices coming from, what are they referencing? This looks like something that will require experimentation, which means I have to wait until I can go up and down stairs to get to the work station... I hate recovering from surgery.
    --------
    Intel Core i7 960 @3.20 Ghz, 24 GB ram, EVGA 6GB GTX980Ti "Classified" driving 2 x HP LA2405.

  6. #66
    Registered User
    Join Date
    May 2017
    Location
    Lampertheim, Germany
    Posts
    101
    The indices are simply the indices from the Arrays, taht are generated by LScript when you enter the editmode (editbegin).
    By entering the editmode in LScript, the engine creates 2 Arrays.
    1 named "polygons" and one named "points". The indices are simply the index of an element in these Arrays.

    I hope this will help.

    Regards
    KANUSO

  7. #67
    Super Member Kryslin's Avatar
    Join Date
    Feb 2009
    Location
    Prescott, IA
    Posts
    1,306
    Here's an interesting one...

    Is it possible to read a bone's weightmap in lscript? It appears you can set one - BoneWeightMapName("name"); - but I don't see anything that looks like you can read the name of the weight map...

    Here's why I'm asking : I have a tool, that assigns weight maps symmetrically, giving identifiers for Right and Left for bones and weight maps. My last revision had added buttons to move up and down the hierarchy, and assign & move to the next bone. I want to add "Next Unassigned" to the buttons, so that you can move to the next bone that doesn't have a weight map assigned to it.

    If it isn't possible, then I have another candidate for conversion to Python.
    --------
    Intel Core i7 960 @3.20 Ghz, 24 GB ram, EVGA 6GB GTX980Ti "Classified" driving 2 x HP LA2405.

  8. #68
    Electron wrangler jwiede's Avatar
    Join Date
    Aug 2007
    Location
    San Jose, CA
    Posts
    6,135
    Quote Originally Posted by Kryslin View Post
    Here's an interesting one...

    Is it possible to read a bone's weightmap in lscript? It appears you can set one - BoneWeightMapName("name"); - but I don't see anything that looks like you can read the name of the weight map...

    Here's why I'm asking : I have a tool, that assigns weight maps symmetrically, giving identifiers for Right and Left for bones and weight maps. My last revision had added buttons to move up and down the hierarchy, and assign & move to the next bone. I want to add "Next Unassigned" to the buttons, so that you can move to the next bone that doesn't have a weight map assigned to it.

    If it isn't possible, then I have another candidate for conversion to Python.
    Possibly mitigated since, but according to this thread, in 2006 Dodgy was asking Newtek to fix lack of read access to that info (as well as some other important info access issues).
    Last edited by jwiede; 10-22-2018 at 01:20 PM.
    John W.
    LW2015.3UB/2018.0.5 on MacPro(12C/24T/10.13.6),32GB RAM, NV 1080ti

  9. #69
    TrueArt Support
    Join Date
    Feb 2003
    Location
    Poland
    Posts
    7,643
    Is it possible to read a bone's weightmap in lscript?
    In Python it's possible to get weight map assigned to specified bone using Bone Info.
    sdk/lwpython2015.3.zip/python2015/globalboneinfo.html
    LightWave Plugins
    Global Materials for LightWave 2018!
    Custom plugin writing. Request a quote.

  10. #70
    Super Member Kryslin's Avatar
    Join Date
    Feb 2009
    Location
    Prescott, IA
    Posts
    1,306
    JWeide: From what I can tell, based on going through the lscript release docs, It hasn't been added. However, until someone from Newtek comes up and says "Hey, its there, here's a code snippet..." then I'm off to Python...

    Sensei : Yeah, I saw that in the Python SDK docs. Looks like I'm moving my Weight assignment tool over to Python...
    --------
    Intel Core i7 960 @3.20 Ghz, 24 GB ram, EVGA 6GB GTX980Ti "Classified" driving 2 x HP LA2405.

  11. #71
    Electron wrangler jwiede's Avatar
    Join Date
    Aug 2007
    Location
    San Jose, CA
    Posts
    6,135
    Quote Originally Posted by Kryslin View Post
    JWeide: From what I can tell, based on going through the lscript release docs, It hasn't been added. However, until someone from Newtek comes up and says "Hey, its there, here's a code snippet..." then I'm off to Python...
    Python approach is direct, might as well use it.
    John W.
    LW2015.3UB/2018.0.5 on MacPro(12C/24T/10.13.6),32GB RAM, NV 1080ti

  12. #72
    Super Member Kryslin's Avatar
    Join Date
    Feb 2009
    Location
    Prescott, IA
    Posts
    1,306
    Ack, phbbbbt, never mind, question answered up thread.
    Last edited by Kryslin; 10-25-2018 at 03:26 PM. Reason: Questiuon Answered in previous posting...
    --------
    Intel Core i7 960 @3.20 Ghz, 24 GB ram, EVGA 6GB GTX980Ti "Classified" driving 2 x HP LA2405.

Page 5 of 5 FirstFirst ... 345

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
  •