Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. Be respectful, on topic and if you see a problem, Flag it.

If you would like to contact our Community Manager personally, feel free to send a private message or an email.

Filter instantiators to not show plans, Mate connector.

DASDAS Member Posts: 5
edited April 2020 in FeatureScript
Hi, I'm starting to handle FeatureScript, I wanted to know if there is a way to filter instantiators to not show plans, Mate connector.


import(path : "13fb9636d7d0307d8a5162a6", version : "efe9ea3071740725a074f15c");

export enum SeletModel
{

    annotation { "Name" : "Type_0" }
    Type_Z,
    annotation { "Name" : "Type_A" }
    Type_A,
    annotation { "Name" : "Type_B" }
    Type_B
}
annotation { "Feature Type Name" : "Instance" }
export const myFeature = defineFeature(function(context is Context, id is Id, definition is map)
    precondition
    {
        // Define the parameters of the feature type
        annotation { "Name" : "REAR WHEEL", }
        definition.SeletModel is SeletModel; //=========

        annotation { "Name" : "Rear_1" }
        isAngle(definition.Rear_1, ANGLE_360_BOUNDS); ///------>

        annotation { "Name" : "Stak" }
        isLength(definition.Area_1, { (millimeter) : [1e-5, 600, 1e5] } as LengthBoundSpec);

        annotation { "Name" : "Reach", "Default" : 50 }
        isLength(definition.Axis_Z, { (millimeter) : [1e-5, 600, 1e5] } as LengthBoundSpec);

    }
    {
        // Define the function's action
        const instantiator = newInstantiator(id + "instantiator");
        if (definition.SeletModel == SeletModel.Type_A)
        {
            addInstance(instantiator, build, {
                        "partQuery" : qConstructionFilter(qEverything(EntityType.BODY), ConstructionObject.NO),   //???
                        "configuration" : {
                                "SeletModel" : SeletModel_conf.Type_B,
                                // "Orientation" : SeletModel_conf.[definition.SeletModel],
                                "Axis_Z" : definition.Axis_Z,
                                "Area_1" : definition.Area_1,
                                "Rotate_1" : definition.Rear_1
                            },
                        "transform" : identityTransform()
                    });
        }
        
        if (definition.SeletModel == SeletModel.Type_B)
        {
            
            addInstance(instantiator, build, {
                         "partQuery" : qConstructionFilter(qEverything(EntityType.BODY), ConstructionObject.NO), // ?????                     
                         "configuration" : {
                                "SeletModel" : SeletModel_conf.Type_A,
                                // "Orientation" : SeletModel_conf.[definition.SeletModel],
                                "Axis_Z" : definition.Axis_Z,
                                "Area_1" : definition.Area_1,
                                "Rotate_1" : definition.Rear_1
                            },
                        "transform" : identityTransform()
                    });
        }
        
          instantiate(context, instantiator);
    });


Comments

  • DASDAS Member Posts: 5
    edited April 2020
    How to filter the "Plane" and lMate connector
    "partQuery" : qConstructionFilter(qEverything(EntityType.BODY), ConstructionObject.NO), // ?????
    https://cad.onshape.com/documents/1c29fe218a63aa8e0fcdc382/w/2591152355d300f944f280c5/e/da4bdb1277ab6124ca3a093c
  • MBartlett21MBartlett21 Member, OS Professional, Developers Posts: 2,050 ✭✭✭✭✭
    @DAS
    Can you use qBodyType(..., BodyType.SOLID)
    mb - draftsman - also FS author: View FeatureScripts
    IR for AS/NZS 1100
  • DASDAS Member Posts: 5

    
    
    Thanks MBartlett21 

    This solves my doubt my problem
    "partQuery" : qBodyType(qEverything(EntityType.BODY), BodyType.SOLID), </code>"partQuery" : qConstructionFilter(qEverything(EntityType.BODY), ConstructionObject.NO), // ?????</pre><br><blockquote class="Quote"> <div><a rel="nofollow">MBartlett21</a> said:</div> <div>@DAS<br>Can you use <code>qBodyType(..., BodyType.SOLID)

    I leave this little example here ...
    
    import(path : "13fb9636d7d0307d8a5162a6", version : "a209c9a751a978707c2f3ea8");
    
    export enum SelecMod
    {
        annotation { "Name" : "NOT" }
        NOTTT,
        annotation { "Name" : "Type_A" }
        Type_A,
        annotation { "Name" : "Type_B" }
        Type_B,
        annotation { "Name" : "Type_C" }
        Type_C
    }
    
    export const SelecType = {
            SelecMod.Type_A : SelecModel_conf.Type_A,
            SelecMod.Type_B : SelecModel_conf.Type_B,
            SelecMod.Type_C : SelecModel_conf.Type_C
    
    
        };
    
    export enum SelecFilter
    {
    
        annotation { "Name" : "Type_A" }
        Type_A,
        annotation { "Name" : "Type_B" }
        Type_B,
        annotation { "Name" : "Type_C" }
        Type_C
    
    }
    
    export const SelecTypeFilter = {
            SelecFilter.Type_A : qConstructionFilter(qEverything(EntityType.BODY), ConstructionObject.YES),
            SelecFilter.Type_B : qConstructionFilter(qEverything(EntityType.BODY), ConstructionObject.NO),
            SelecFilter.Type_C : qBodyType(qEverything(EntityType.BODY), BodyType.SOLID)
    
            // SelecTypeFilter[definition.SelecFilter]
        };
    
    annotation { "Feature Type Name" : "Instance" }
    export const myFeature = defineFeature(function(context is Context, id is Id, definition is map)
        precondition
        {
            // Define the parameters of the feature type
            annotation { "Name" : "REAR WHEEL", } //=========
            definition.SelecModel is SelecMod;
    
            annotation { "Name" : "REAR WHEEL", } //=========
            definition.SelecFilter is SelecFilter;
    
            annotation { "Name" : "Rear_1" }
            isAngle(definition.Rear_1, ANGLE_360_BOUNDS); ///------>
    
            annotation { "Name" : "Stak" }
            isLength(definition.Area_1, { (millimeter) : [1e-5, 600, 1e5] } as LengthBoundSpec);
    
            annotation { "Name" : "Reach", "Default" : 50 }
            isLength(definition.Axis_Z, { (millimeter) : [1e-5, 600, 1e5] } as LengthBoundSpec);
    
        }
        {
            // Define the function's action
            const instantiator = newInstantiator(id + "instantiator");
            if (definition.SelecModel != SelecMod.NOTTT)
            {
                addInstance(instantiator, build, {
                            // include sketches, only exclude default
                            "partQuery" : SelecTypeFilter[definition.SelecFilter],
                            "configuration" : {
                                    "SelecModel" : SelecType[definition.SelecModel], //SelecModel_conf.Type_A,
                                    "Axis_Z" : definition.Axis_Z,
                                    "Area_1" : definition.Area_1,
                                    "Rotate_1" : definition.Rear_1,
                                },
                            "transform" : identityTransform()
                        });
            }
    
            instantiate(context, instantiator);
        });
    
    <br>

Sign In or Register to comment.