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.

Transform Help Request

owen_sparksowen_sparks Member, Developers Posts: 2,284 PRO
edited April 4 in FeatureScript
Hi folks.

Another newbie FS request.  Please can I have some help with a transform?  I'll admit I'm finding the "help" hard to deal with.  It's a bit like Microsoft's help in that you need to be proficient in the subject to understand the help in which case you wouldn't be reading it in the first place...  Actually that's a bit unkind, if you think of it as a technical reference for looking up parameters then it fits that use case well but if you're a newbie it's a whole different story.  I've got this far mostly with help from OS staff and helpful forum users. (Thanks for that BTW.)

Background:-
Feature is a part of my company specific standard content widget.

Desired functionality is to select a sketch point or mate connector and the feature will derive in a desired part and optionally create the appropriate void for it to fit into.  In this example we're using a type of bolt often used in furniture making. 


We have a configurable PS to build the bolt for us, and a solid model of the void we require for that series of parts. 


The void is modeled in a separate PS around the origin.
By controlling where this "void part" is placed we can allow the bolt to be positioned on the surface of the target part or to have it recessed such that it is flush with the surface.








It's this additional "flush" transform I'm stuck on, the rest is working as intended.  I have an initial transform to take the part from the source studio and move it to the target sketch point or MC. 

 try silent //Build Transform as if target is Mate Connector
                            {
                                transform  = toWorld(evMateConnector(context, {
                                    "mateConnector" : TargetPoints[i]       
                                    }));
                               
                                if (definition.isFlipped)
                                            {
                                               
                                            }
                                   
                                debug(context, "LoopCounter:- " ~ i);
                                debug(context, "is a Mate Connector");
                            }              
                           
                            try silent //Build Transform as if target is Sketch Point
                            {
                                var skPlane = evOwnerSketchPlane(context, {
                                        "entity" : TargetPoints[i]
                                    });
                               
                                skPlane.origin = evVertexPoint(context, {
                                            "vertex" : TargetPoints[i]
                                        });
                               
                                if (definition.isFlipped)
                                            {
                                                skPlane.normal *= -1;
                                                skPlane.x *= -1;
                                            }
                               
                                transform  = toWorld(coordSystem(skPlane));
                               
                                debug(context, "LoopCounter:- " ~ i);
                                debug(context, "is a Sketch Vertex");
                            }

Later:-

//Add void if selected
if (definition.AddConnectorBoltVoid)
{
const instantiatorVoid = newInstantiator(id + i + "instantiateVoid");
addInstance(instantiatorVoid, ConnectorBoltVoid2::build, { "transform" : transform} );

instantiate(context, instantiatorVoid);

//Boolean remove Void from TargetPart

opBoolean(context, id + i + "booleanVoid", {
"tools" : qCreatedBy(id + i + "instantiateVoid", EntityType.BODY),
"targets" : definition.TargetPart,
"operationType" : BooleanOperationType.SUBTRACTION
});
}
So my question is how do I apply an additional transform to my part before the boolean?  I have a variable defined but I'm at a loss as to what to do with it. 

var FlushTransformDistance is ValueWithUnits = 2.25*millimeter;
I understand we can perform multiple transforms by multiplying them together, and we can build one with a vector but that's about it.  How to build this?  How do we have it apply to local space?   

Have tried for a while and am at tearing hair out stage so am asking here before I break something expensive...

Thanks all,

Owen S.

Production Engineer
HWM-Water Ltd
Tagged:

Best Answer

  • konstantin_shiriazdanovkonstantin_shiriazdanov Posts: 901 ✭✭✭✭✭
    edited April 4 Accepted Answer
    the general idea is if you need some additional transform (the moovement of the tool body) you can make it before the main transform and the resulting transform would be a composition of 2, in OS it wil be a product of 2 transforms:
    if (definition.AddConnectorBoltVoid)
    {
    transform =  transform * transform(vector(0,0,-0.005)*meter)
    ...
    }
    note that it is not a good idea to name a variable as a builtin function so i would name your transform variable as tr

Answers

  • konstantin_shiriazdanovkonstantin_shiriazdanov Member Posts: 901 ✭✭✭✭✭
    edited April 4 Accepted Answer
    the general idea is if you need some additional transform (the moovement of the tool body) you can make it before the main transform and the resulting transform would be a composition of 2, in OS it wil be a product of 2 transforms:
    if (definition.AddConnectorBoltVoid)
    {
    transform =  transform * transform(vector(0,0,-0.005)*meter)
    ...
    }
    note that it is not a good idea to name a variable as a builtin function so i would name your transform variable as tr
  • owen_sparksowen_sparks Member, Developers Posts: 2,284 PRO
    edited April 4
    Hi @konstantin_shiriazdanov and thanks for your help, it's appreciated. :+1:

    I swear I tried exactly that right at the beginning, and all seemed well.  The featurestudio accepted the code, but it fell over as soon as it was run.  Your "note" on "builtins" is of course the culprit, as soon as the code was changed to
    Mytransform =  Mytransform * transform(vector(0,0,-2.25)*millimeter);
    it all worked as expected.

     Can we beat up Onshape on this point?

    It would be nice if the IDE rejected variable names that are reserved!

    Cheers all,
    Owen S.

    Production Engineer
    HWM-Water Ltd
  • Jake_RosenfeldJake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,295
    @owen_sparks

    Good find.  Our standard practice is to say 'const xform = toWorld(...)'

    I'll write up a bug.
    Jake Rosenfeld - Modeling Team
  • owen_sparksowen_sparks Member, Developers Posts: 2,284 PRO
    @owen_sparks

    Good find.  Our standard practice is to say 'const xform = toWorld(...)'

    I'll write up a bug.
    Thanks Jake, Onshape's commitment to address even small niggles like this is impressive.
    Owen S.
    Production Engineer
    HWM-Water Ltd
Sign In or Register to comment.