Hi All,
A simple question I can't find the answer to, so I'm likely missing something obvious, is how do I delete a sketch curve, line, arc etc.? I can't find a delete or remove method that would get the job done.
By way of example if I use the sketch->offset method, I would like to delete the input curves in the sketch and keep only the offset curves.
Thanks,
Rod.
Solved! Go to Solution.
Solved by ekinsb. Go to Solution.
All objects that can be deleted support the the deleteMe method. If you want to delete a sketch line, you first need to get the SketchLine object you want to delete and then call the deleteMe method.
Thanks Brian!
That working for me with collections like SketchLines, SketchCurves etc.
Follow-up question if I may. How can I make that works for objects in a generic ObjectCollection?
If I try something like objCol->item(0)->deleteMe();
I get the error: No member named 'deleteMe' in 'ask::core::Base'
In the code below I'm trying to delete the curves contained in the collection offsetCurves generated by the offset method in the sketch sketchIn.
Thanks!
Rod.
bool kerfSketch(Ptr<Sketch> sketchIn, Ptr<Sketch> sketchOut, double kerf, double xOffset, double yOffset, double zOffset)
{
// Compute profiles etc.
sketchIn->isComputeDeferred(true);
Ptr<SketchCurves> curvesIn = sketchIn->sketchCurves();
if (!curvesIn) return false;
// Do we need to flip the axis
double xInv = 1;
double yInv = 1;
Ptr<Vector3D> xVector = sketchIn->xDirection();
Ptr<Vector3D> yVector = sketchIn->yDirection();
if (std::min(std::min(xVector->x(),xVector->y()),xVector->z())<0) xInv = -1;
if (std::min(std::min(yVector->x(),yVector->y()),yVector->z())<0) yInv = -1;
// Get the Profiles collection
Ptr<Profiles> profiles = sketchIn->profiles();
Ptr<ObjectCollection> curvesForOffset = ObjectCollection::create();
Ptr<ObjectCollection> offsetCurves = ObjectCollection::create();
curvesForOffset = sketchIn->findConnectedCurves(curvesIn->item(0));
offsetCurves = sketchIn->offset(curvesForOffset, Point3D::create(100,100,100), kerf/2);
if (!offsetCurves) return false;
// Create a transform to do move
Ptr<Vector3D> vector = adsk::core::Vector3D::create(xOffset*xInv, yOffset*yInv, zOffset);
if(!vector)
return false;
Ptr<Matrix3D> transform = adsk::core::Matrix3D::create();
if(!transform)
return false;
transform->translation(vector);
sketchIn->copy(offsetCurves, transform, sketchOut);
sketchIn->isComputeDeferred(false);
return true;
}
Hi Brian, could you please elaborate on the "DeleteMe Method" is it a code command? If so where would I insert it?
I have two small lines on a body which I would like to simply delete but when I select either of them and try to delete nothing happens. I'm clearly not very smart as this would seem to be the most elementary of functions in any CAD programme?
Many thanks
Matt
I think you might be confusing sketch geometry from other types of geometry. Sketch geometry lives in and is owned by a sketch. An easy way to understand what's in a sketch is to play with the visibility setting of a sketch. By toggling the light bulb beside the sketch in the browser it will turn it on and off and will make it obvious what's in a particular sketch. You referred to lines on a "body". The term "body" refers to something completely different that sketch geometry. You can understand what's associated with a body by also turning its visibility on and off. Editing a body is very different than editing a sketch. You edit a body by performing feature operations.
Talking specifically about a body and delete, let's say that you've created a solid box. You could say that there are 12 lines on the box but this isn't really true. There are 12 edges, which represent the intersection of faces. It's like having a real wooden block. The edges of the block don't exist on their own but are a by-product of how the sides of block meet. It doesn't make sense to say you want to delete one of the edges of the block. What you would need to do is somehow modify the faces in a way that they no longer intersect to create that edge.
And I might be misinterpreting what you're trying to do. 🙂