How to find the id of several bodies in "Query" with several mouse Picks

Fda
Fda Member Posts: 42 ✭✭
I am trying to pass the body id to rename solids with a string + i (1,2,3 ...... etc)
annotation { "Feature Type Name" : "Name my_Part" }
export const myFeature = defineFeature(function(context is Context, id is Id, definition is map)
    precondition
    {
        // Define the parameters of the feature type
        annotation { "Name" : "Nome", "Default" : "Part_" }
        definition.Name_Part  is string;

        annotation { "Name" : "My Query", "Filter" : EntityType.BODY, "MaxNumberOfPicks" : 20 }
        definition.parts is Query;


    }
    {
        // Define the function's action
        var myString = definition.Name_Part;

        var parts is array = evaluateQuery(context, definition.parts);

        //println(parts[1]);

        for (var i = 0; i < size(definition.Name_Part); i += 1)
        {

            //println(someString~i);
            setProperty(context, {
                        "entities" : definition.parts,
                        "propertyType" : PropertyType.NAME,
                        "value" : myString ~ i
                    });


        }
    });


Best Answer

Answers

  • konstantin_shiriazdanov
    konstantin_shiriazdanov Member Posts: 1,221 ✭✭✭✭✭
    edited March 2020
    for (var i = 0; i < size(definition.Name_Part); i += 1)
            {
    setProperty(context, { "entities" : parts[i], "propertyType" : PropertyType.NAME, "value" : myString ~ i });
    }
    this should work, but you may need to reset part studio properties first, if you renamed parts manually.


  • Fda
    Fda Member Posts: 42 ✭✭
    Thanks konstantin_shiriazdanov, but it doesn't work.
    I need to find a way to go to
     "entities":
    The id one of each "body"

    But I am somewhat lost.

    for (var i = 0; i < size(definition.Name_Part); i += 1)
            {
    setProperty(context, { "entities" : parts[i], "propertyType" : PropertyType.NAME, "value" : myString ~ i });
    }
    this should work, but you may need to reset part studio properties first, if you renamed parts manually.




  • Fda
    Fda Member Posts: 42 ✭✭
    This code works :)
    Thanks konstantin_shiriazdanov
    I leave it in the forum in case someone can help you.
    annotation { "Feature Type Name" : "Name myPart" }
    export const myFeature = defineFeature(function(context is Context, id is Id, definition is map)
        precondition
        {
            // Define the parameters of the feature type
            annotation { "Name" : "Nome", "Default" : "Part_" }
            definition.Name_Part is string;
    
            annotation { "Name" : "My Query", "Filter" : EntityType.BODY}
            definition.parts is Query;
    
    
        }
        {
            // Define the function's action
            var myString = definition.Name_Part;
            var parts is array = evaluateQuery(context, definition.parts);
    
            for (var i = 0; i < size(parts); i += 1)
            {
                setProperty(context, {
                            "entities" :parts[i],
                            "propertyType" : PropertyType.NAME,
                            "value" : myString ~ i
                        });
    
                
            }
        });