Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- 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.
Flip Normal in Transform Using Mate Connector?
owen_sparks
Member, Developers Posts: 2,660 PRO
Hi folks.
I'm after some help with flipping a normal in a transform. I'm using either a sketch point or a MC as an input, and then the UIHint.OPPOSITE_DIRECTION driving definition.isFlipped
Owen.
I'm after some help with flipping a normal in a transform. I'm using either a sketch point or a MC as an input, and then the UIHint.OPPOSITE_DIRECTION driving definition.isFlipped
For the sketch point we have this code working just fine (thanks previous helpers):-
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;
}
skPlane.x = rotationAround(line(skPlane.origin, skPlane.normal), (-definition.rotation)).linear * skPlane.x;
Mytransform = toWorld(coordSystem(skPlane));
debug(context, "LoopCounter:- " ~ i);
debug(context, "is a Sketch Vertex");
}
{
var skPlane = evOwnerSketchPlane(context, {
"entity" : TargetPoints[i]
});
skPlane.origin = evVertexPoint(context, {
"vertex" : TargetPoints[i]
});
if (definition.isFlipped)
{
skPlane.normal *= -1;
skPlane.x *= -1;
}
skPlane.x = rotationAround(line(skPlane.origin, skPlane.normal), (-definition.rotation)).linear * skPlane.x;
Mytransform = toWorld(coordSystem(skPlane));
debug(context, "LoopCounter:- " ~ i);
debug(context, "is a Sketch Vertex");
}
Now I'd like to do the same thing for the MC version:-
Try silent //Build Transform as if target is Mate Connector
{
Mytransform = toWorld(evMateConnector(context, {
"mateConnector" : TargetPoints[i]
}));
if (definition.isFlipped)
{
//<> WHAT GOES HERE?
}
debug(context, "LoopCounter:- " ~ i);
debug(context, "is a Mate Connector");
}
Thanks,{
Mytransform = toWorld(evMateConnector(context, {
"mateConnector" : TargetPoints[i]
}));
if (definition.isFlipped)
{
//<> WHAT GOES HERE?
}
debug(context, "LoopCounter:- " ~ i);
debug(context, "is a Mate Connector");
}
Owen.
Business Systems and Configuration Controller
HWM-Water Ltd
HWM-Water Ltd
Tagged:
0
Best Answers
-
konstantin_shiriazdanov Member Posts: 1,221 ✭✭✭✭✭evMateConnector returns coordSystem, isn't it? And after it is evaluated it is the right moment to flip it's zAxis.
1 -
owen_sparks Member, Developers Posts: 2,660 PROAh-ha, you're right.Thanks @konstantin_shiriazdanovEventually found this in the documentation:-So this works exactly as needed:-var cSys is CoordSystem = evMateConnector(context, {
"mateConnector" : TargetPoints[i]
});
if (definition.isFlipped)
{
cSys.zAxis*=-1;
}
Mytransform = toWorld(cSys);Thanks for taking the time to help the neewbiesCheers,Owen S.
Business Systems and Configuration Controller
HWM-Water Ltd2
Answers
//addInstance(instantiator, HeatsertVoidForM3x5_4mmx8mm::build, { "transform" : toWorld(coordSystem(skPlane))} );
const shapeInstance = addInstance(instantiator, imports[toString( definition.MiscSelected)], { "transform" : Mytransform} );
instantiate(context, instantiator);
HWM-Water Ltd
Hi again. Sorry to be a pain. I knew I should have posted the full code. The coordsystem above is in the part of the code that accepts sketch points. If the user selects a MC then that part of the code will never run and we go straight from evaluating the mate connector to instancing a part. So in summary this is all we have to work with so far.:-
"mateConnector" : TargetPoints[i]
}));
var instantiator = newInstantiator(id + i + "instantiate");
const shapeInstance = addInstance(instantiator, imports[toString( definition.LoggerInputSelected)], { "transform" : Mytransform} );
instantiate(context, instantiator);
HWM-Water Ltd
"mateConnector" : TargetPoints[i]
});
if (definition.isFlipped)
{
cSys.zAxis*=-1;
}
Mytransform = toWorld(cSys);
HWM-Water Ltd