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.

simple manipulator tutorial?

adamohernadamohern Member, OS Professional Posts: 216 PRO
Is there a simple 3D manipulator tutorial or example anywhere? The extrude tool, for example, clearly implements manipulators, but it's an extremely complex tool, so it's hard to tell what a simpler example might look like. If not, is that something that could be created fairly quickly? I just want to haul simple length values around.

Comments

  • kevin_o_toole_1kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565
    Here a quick example of a manipulator (coming soon to a documentation page near you!)

    annotation { "Feature Type Name" : "Fake extrude",
            "Manipulator Change Function" : "fakeExtrudeManipulatorChange" }
    export const fakeExtrude = defineFeature(function(context is Context, id is Id, definition is map)
        precondition
        {
            annotation { "Name" : "Faces to extrude", "Filter" : EntityType.FACE }
            definition.faces is Query;
            annotation { "Name" : "My Length" }
            isLength(definition.depth, LENGTH_BOUNDS);
            annotation { "Name" : "Opposite direction", "UIHint" : "OPPOSITE_DIRECTION" }
            definition.shouldFlip is boolean;
        }
        {
            var extrudePlane is Plane = evFaceTangentPlane(context, {
                    "face" : definition.faces,
                    "parameter" : vector(0.5, 0.5)
            });
            var extrudeManipulator is Manipulator = linearManipulator(
                    extrudePlane.origin,
                    extrudePlane.normal,
                    definition.shouldFlip ? definition.depth : -definition.depth
            );
            addManipulators(context, id, {
                    "myManipulator" : extrudeManipulator
            });
            opExtrude(context, id + "extrude1", {
                    "entities" : definition.faces,
                    "direction" : definition.shouldFlip ? extrudePlane.normal : -extrudePlane.normal,
                    "endBound" : BoundingType.BLIND,
                    "endDepth" : definition.depth
            });
        }, {});
    export function fakeExtrudeManipulatorChange(context is Context, definition is map, newManipulators is map) returns map
    {
        var newDepth is ValueWithUnits = newManipulators["myManipulator"].offset;
        definition.depth = abs(newDepth);
        definition.shouldFlip = newDepth > 0;
        return definition;
    }
  • adamohernadamohern Member, OS Professional Posts: 216 PRO
    You are a true hero, Kevin. Thank you.
  • kevin_o_toole_1kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565
    Full documentation for the manipulator change function can now be found here.
Sign In or Register to comment.