edit : See here for example answer
Untrim face or surface with temporary geometry using SOLIDWORKS API
Hi Guys
I'm looking for the best method to Untrim a face from my model.
Just to be clear I'm not talking about Inserting an Untrim Feature, but using temp bodies.
I had a look through IFace2 and ISurface but nothing jumped out at me.
I've managed to make a box of the correct size using GetUVBounds(), but then I'm not sure what to to with the rotation part of the transform as you can see below.
I think I have a way to do it, but it seems way more complicated than it should be.
Given an IFace2 object that's planar is there a straight forward way?
Thanks
SolidworksApi/macros
Sorry, I'm a bit slow on the uptake this morning... What is it you're shooting for? It looks like what's up there is an end-view of some kind of millwork/molding, and you're trying to create a rectangular surface body that corresponds to the raw size, in place?
That's so much nicer.
I did think of using iso curves, and was going to try them out, but it took far longer for me to get this working than I hoped.
I had an annoying typo bug in one of my loops, that took ages to spot.
I really like how you just keep it simple.
One of the reasons I chose to try creating my own lines is because that's part of next goal. - they're not scary anymore!
I'll add the link to your post to my question, so people can see it straight away.
I learnt a lot yesterday and already today.
Very good solution, Rob! You might also employ your idea with iso curves instead of explicitly building the boundary lines. In this case you will be able to untrim any surface (not just planar). If anyone needs here is VBA example: Untrim face or surface with temporary geometry using SOLIDWORKS API . By some reasons CreateTrimmedSheetX doesn't like B-spline curves and always fails for me, only works for planar and cylindrical faces with linear and arc curves. If anyone has any idea - would be nice if you can share. Basically just run the macro on any surface created from spline - it would fail, but will work OK for any planar surface or any cylindrical surface.
Well, it actually took me longer to do than the other way.
I had a small bug I didn't spot for a quite a while.
I bet there's a much better way, but it does work.
Thanks yet again Artem
Awesome Artem!
I knew there'd be a simpler way. (Where were you 5 hours ago ;p?)
Hi Josh
I negated the angle and it seems to have done the trick
Math[s] makes my head hurt so much I'm absolutely wiped out
You can try ISurface::Copy (this should restore an untrimmed surface), then get uv bounds of original face and create curves box from the corners and CreateTrimmedSheet. I believe this is similar to how original untrim works.
Hi Rob,
If you could use Modeler::CreateBodyFromBox() to generate a Surface body then you do not need CreatePlanarSurface2() API call. You can directly use that surface body in the last step.
I knew that CreatePlanarSurface() is obsolete now but it still useful here. This is because we do not need the plane orientation.
Additionally, you can use the Face Edges to get the correct orientation. May be the linear edge with maximum length is a good starting point for you.
Hope it helps!!!
Rajat Jain
Is your normal vector just backwards?
Hi Rajat
I have a feeling I haven't specified my problem accurately enough, or I misunderstand your answer.
It's calculating the untrimmed face bounds that I'm having difficulty with.
But your answer has been very useful, as I have discovered a few new things in the API.
Notably you can use CreateBodyFromBox to create a Surface directly, which will save me two method calls.
What else I found interesting is that
System.object CreatePlanarSurface( System.object VRootPoint, System.object VNormal )
is marked as Obsolete and in
System.object CreatePlanarSurface2( System.object VRootPoint, System.object VNormal, System.object VRef )
We know have a VRef parameter
Array of 3 doubles (x,y,z) defining the x-axis on the planar surface with root point, VRootPoint; this vector must be perpendicular to VNormal
I would expect a PlanesParams2 property, but I found no way of getting this other than by something like this
I'm getting a lot closer.. It's the right angle (but the wrong way)
Thankyou Rajat
I'm trying to follow your instructions.. will report back
Hello Rob,
I think there can be a simpler approach. Kindly try these steps: -
Hope this helps!!!
Rajat Jain
After much hunting around in the API I think I can calculate the missing information using MakeIsoCurve Method (ISurface) which returns a Curve. I can then use LineParams Property (ICurve) to calculate the angle.
Well that's the present plan
I'm beginning to understand why it's not working..
I am creating a transform from the PlaneParams of the Face Surface.
I was hoping that I could create a new planar surface at the origin using the uvBounds and then apply an Inverse Transformation.
But the plane params are just a Root Point and Normal Axis, so there is no information regarding orientation on the plane, just the plane itself.
So categorically this approach cannot work.
I need a new approach.
I could possibly use a bounding box, but surely - there must be something obvious I'm missing?
Yep that's about right.
What I want is the equivalent to this