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.
Guidance on planeToWorld and auto placing
Dylan_Stewart
Member, Developers Posts: 107 PRO
Hello everyone, I am building on the collaboration of the 'Table Creator'
I'm taking it to a different level. This time I am building a wall and placing a picture on the wall.
I have most of the code already written, but if you look at what it creates you'll see that the picture ends up out in space.....
I know it has to do with the 'xaxis, zaxis and skplane' and I have tried messing around with it, but can't seem to get it to work....
Any and all help is always appreciated.
here is the code:
and here is a picture of the current outcome:

I'm taking it to a different level. This time I am building a wall and placing a picture on the wall.
I have most of the code already written, but if you look at what it creates you'll see that the picture ends up out in space.....
I know it has to do with the 'xaxis, zaxis and skplane' and I have tried messing around with it, but can't seem to get it to work....
Any and all help is always appreciated.
here is the code:
FeatureScript 392;
import(path : "onshape/std/geometry.fs", version : "392.0");
LEFTPICTURE::import(path : "7b3e5216afeadf2e82a23338", version : "4f6d8e962c4c177da958e760");
RIGHTPICTURE::import(path : "00f9b4e35f94bf19906cac85", version : "6488a55aa4fccb9bb7058852");
export enum Side
{
LEFT,
RIGHT
}
annotation { "Feature Type Name" : "Wall Creator" }
export const myFeature = defineFeature(function(context is Context, id is Id, definition is map)
precondition
{
annotation { "Name" : "Wall Height" }
isLength(definition.wallHeight, LENGTH_BOUNDS);
annotation { "Name" : "Wall Width" }
isLength(definition.wallWidth, LENGTH_BOUNDS);
annotation { "Name" : "Side" }
definition.mySide is Side;
}
{
var height = definition.wallHeight;
var width = definition.wallWidth;
var wallVerticies = [
vector(0, 0) * inch,
vector(0 * inch, height),
vector(height, width),
vector(width, 0 * inch), ];
if (definition.mySide == Side.LEFT)
{
var xPoint = width / 4;
var yPoint = (height / 4) * 3;
var pointVerticies = [vector(xPoint, yPoint)];
var leftSketch = newSketch(context, id + "sketch1", {
"sketchPlane" : qCreatedBy(makeId("Front"), EntityType.FACE)
});
skLineSegment(leftSketch, "leftWall", {
"start" : wallVerticies[0],
"end" : wallVerticies[1]
});
skLineSegment(leftSketch, "topWall", {
"start" : wallVerticies[1],
"end" : wallVerticies[2]
});
skLineSegment(leftSketch, "rightWall", {
"start" : wallVerticies[2],
"end" : wallVerticies[3]
});
skLineSegment(leftSketch, "botWall", {
"start" : wallVerticies[3],
"end" : wallVerticies[0]
});
skPoint(leftSketch, "point1", {
"position" : pointVerticies[0]
});
skSolve(leftSketch);
var wallRegion = qSketchRegion(id + "sketch1");
extrude(context, id + "extrude1", {
"entities" : wallRegion,
"endBound" : BoundingType.SYMMETRIC,
"depth" : 0.5 * inch
});
var origin = vector(0, 0, 0) * inch;
var xaxis = vector(0, 0, 1) * inch;
var zaxis = vector(1, 0, 0) * inch;
var skplane = plane(origin, xaxis, zaxis);
var point = planeToWorld(skplane, pointVerticies[0]);
var picImport is Context = LEFTPICTURE::build();
opDeleteBodies(picImport, id + "deleteDefaultGeometry", {
"entities" : qUnion([
qConstructionFilter(qBodyType(qEverything(EntityType.BODY), BodyType.SHEET), ConstructionObject.YES),
qCreatedBy(makeId("Origin"))
])
});
opMergeContexts(context, id + "mergeContexts", {
"contextFrom" : picImport
});
var importedPart = qCreatedBy(id + "mergeContexts", EntityType.BODY);
opTransform(context, id + "transform", { "bodies" : importedPart, "transform" : transform(point) });
}
if (definition.mySide == Side.RIGHT)
{
var xPoint = (width / 4) * 3;
var yPoint = (height / 4) * 3;
var pointVerticies = [vector(xPoint, yPoint)];
var leftSketch = newSketch(context, id + "sketch1", {
"sketchPlane" : qCreatedBy(makeId("Front"), EntityType.FACE)
});
skLineSegment(leftSketch, "leftWall", {
"start" : wallVerticies[0],
"end" : wallVerticies[1]
});
skLineSegment(leftSketch, "topWall", {
"start" : wallVerticies[1],
"end" : wallVerticies[2]
});
skLineSegment(leftSketch, "rightWall", {
"start" : wallVerticies[2],
"end" : wallVerticies[3]
});
skLineSegment(leftSketch, "botWall", {
"start" : wallVerticies[3],
"end" : wallVerticies[0]
});
skPoint(leftSketch, "point1", {
"position" : pointVerticies[0]
});
skSolve(leftSketch);
var wallRegion = qSketchRegion(id + "sketch1");
extrude(context, id + "extrude1", {
"entities" : wallRegion,
"endBound" : BoundingType.SYMMETRIC,
"depth" : 0.5 * inch
});
var origin = vector(0, 0, 0) * inch;
var xaxis = vector(0, 0, 1) * inch;
var zaxis = vector(1, 0, 0) * inch;
var skplane = plane(origin, xaxis, zaxis);
var point = planeToWorld(skplane, pointVerticies[0]);
var picImport is Context = RIGHTPICTURE::build();
opDeleteBodies(picImport, id + "deleteDefaultGeometry", {
"entities" : qUnion([
qConstructionFilter(qBodyType(qEverything(EntityType.BODY), BodyType.SHEET), ConstructionObject.YES),
qCreatedBy(makeId("Origin"))
])
});
opMergeContexts(context, id + "mergeContexts", {
"contextFrom" : picImport
});
var importedPart = qCreatedBy(id + "mergeContexts", EntityType.BODY);
opTransform(context, id + "transform", { "bodies" : importedPart, "transform" : transform(point) });
}
});and here is a picture of the current outcome:

Digital Engineering
Tagged:
0
Best Answer
-
Dylan_Stewart
Member, Developers Posts: 107 PRO
For anyone that may have been interested, @lougallo helped me figure this out.</code>var origin = vector(0, 0, 0) * inch;</pre><pre><code> var xaxis = vector(0, -1, 0) * inch; var zaxis = vector(0, 0, 1) * inch; var skplane = plane(origin, xaxis, zaxis<span>);</span>
Thanks!!Digital Engineering5
Answers
https://cad.onshape.com/documents/9f07c97a12397e67b3eb5d1d/w/e09d3089ee4f5d6c57ccd4ca/e/01a5c14d9b4c41f33c1bec90
</code>var origin = vector(0, 0, 0) * inch;</pre><pre><code> var xaxis = vector(0, -1, 0) * inch; var zaxis = vector(0, 0, 1) * inch; var skplane = plane(origin, xaxis, zaxis<span>);</span>Thanks!!