Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CATIA Sketch 2D "Bounding Rectangle"

Status
Not open for further replies.

2briancox

Aerospace
Dec 22, 2014
34
0
0
US
I'm now at the point I often run into with CATIA VBA. I know what I want to do. I've spent hours looking for the tools in forums and in the help files, that I need to get it done. And I end up getting nowhere.

I want to make a Macro that creates a Bounding Rectangle with the default axis system of all geometry that exists in a sketch within a CATPart. I think my strategy should be to go through every geometry, find its X and Y extrema (largest and smallest) and keep cycling until I know the largest and smallest X and Y of all geometry and make a box using that data.

I found HybridShapeExtremum, but that seems to only apply to geometry from the GSD workbench, and I want sketch geometry. Would anyone know how to go about solving this?
 
Replies continue below

Recommended for you

There is not an extreme command inside the Sketching workbench. What about finding the extreme points of the sketch in the direction of Sketch H,V. Project the points into the sketch and create a box from this geometry?

I attached a bounding box script that would need a little modification to produce what you are looking for.

Regards,
Derek


Win 7
23SP5/24SP3, 3DVIA Composer 2015
 
 http://files.engineering.com/getfile.aspx?folder=e5d758ba-f7df-4029-bf94-b6ed6fd14934&file=BoundingBox.CATScript
Yes, thank you DBezaire. I do have that script. It is a part of the CATIA Portable Script Center from Fedro. But in order to use that for my sketch, I would have to Sweep the Sketch and create an Axis System in the orientation of the Sweep, and then delete all of that to get my data, and then go back in the sketch and use that data to create the rectangle ...

It seems like I wouldn't be doing all of this in the most efficient way. Surely there has to be a more efficient approach. Maybe?
 
Brian, in my opinion, not everything should be solved in vb (even if I'm a big fun of solving different tasks in this way) and this "bounding box" is one of them.

Maybe is better to create a UDF based on something similar like here . The idea is to create a rectangle around the sketch and rotate that rectangle (or the sketch) in order to obtain the minimum area for rectangle. In this way you will obtain the minimum x and y dimensions. Anyway, I don't think there is a quick solution for this.

I suppose you want this especially for unfolded SMD parts (I know this is a problem for brackets with complex shape).

Regards
Fernando

- Romania
- EU
 
Thank you, fedro! That gave me a very good idea.

My box can be slightly large if needed without causing me any issue. So I will create equally spaced construction points on all curves of maybe 0.05" spacing, then take the max/min X and max/min Y of each point. Then create a box around those dimensions and oversize it by 0.025" on each side. That will guarantee that all curves are within the bounding box.

Perfect!
 
Ok. So it appears I was over-eager. Is there no way to create points in a sketch through VBA by creating evenly spaced points along a line, circle, nurb, etc?
 
Status
Not open for further replies.
Back
Top