How to put perimeters of a face from one part to another part using VBA?

How to put perimeters of a face from one part to another part using VBA?

revans1234
Enthusiast Enthusiast
788 Views
7 Replies
Message 1 of 8

How to put perimeters of a face from one part to another part using VBA?

revans1234
Enthusiast
Enthusiast

Hello,

 

I draw sheet metal parts for fabrications (machines, trolleys, brackets, etc.), and we use a system where we cut tabs and slots in the laser cut parts so the welders slot it together and weld from that. This way they don't need jigs or spend a long time setting up. The welders love it, but the drawing involved is considerable.

 

The process has a lot of VBA routines to help, but one area that is very slow by comparison is to derive the slot positions. At the moment this is done by selecting a sketch, and them selecting the geometry, typically the end of the tab, which then projects a rectangle to the sketch.

 

I was wondering if I could write or copy code that drew any intersections onto a sketch on one of the parts. Assuming the first part, second part, sketch itself have already been selected, it is possible to add to the sketch any intersection points between the two parts and join them together?

 

In all cases-

-the tabs pass through the second part at right angles

-the tabs are 15mm long and 1.2m tall (the metal thickness)- so if only points we recovered the routine could guess the tabs by point to point distance and draw round the points as rectangles.

-speed is not essential- it can cycle through every entity on the first part.

 

A clear example of intersection on a sketch from an entity on another part would solve it.

 

Any ideas? Has anyone has a similar problem, and how did you fix it? The Inventor is 2016.

 

Many thanks for any suggestions, or links to more information.

 

Regards,

 

Roger.

 

0 Likes
Accepted solutions (1)
789 Views
7 Replies
Replies (7)
Message 2 of 8

bradeneuropeArthur
Mentor
Mentor
I don't exactly get what you mean. But if I understand correctly then you want to clamp or bolt parts together before welding! Therefore you need to create holes and slots to fit together. Is this correct

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 8

revans1234
Enthusiast
Enthusiast

Hello bradeneurope, thank you for your reply.

 

Yes you are correct, but the system itself is not in doubt, it is how to draw it quickly.

 

The edge of a sheet metal part has tabs or finger on its edge, these fit into slots cut into the facing part. The slots are drawn typ 0.5mm bigger all the way round which allows for the laser cut tolerance.

 

When the parts are assembled they stay together without bolts- the most that is needed is a magnetic clamp.

 

So to draw it, rectangles are drawn on the edges of the parts, and filled in with the face command. This used to be done by drawing one rectangle and using an array to repeat it, but I am working on a VBA method to draw all the rectangles based on the sketch edge length. This seems fine to do.

 

The other part needs the corresponding slots. As mentioned, these are made at the moment by projection onto a sketch, which is totally manual, and very boring.

 

I guess what I was thinking off was a VBA procedure that was given both parts and the sketch on the slot side part, and that cycled through every line entity on the tab part, and draw a point on the sketch if that line passed through it.

 

Another routine then cycles through all the points, measuring the distance between them. This would join the points with lines if it notices a distance expecting from a tab passing through.

 

The next part creates a rectangle around the detected ones with the offset of size.

 

It's detecting how an entity passes through a sketch plane that I haven't got an idea- I am sure it must be one line command.

 

I hope this makes it clearer.

 

Thanks again for your reply,

 

Roger.

0 Likes
Message 4 of 8

revans1234
Enthusiast
Enthusiast

Further to this I have written all the encapsulating code which can find lines likely to intersect and can cycle through them against a plane, the problem remains on getting the intersection. So far I have got two methods-

 

-first principles from the line and plane points.

 

-using the TransientGeometry.CurveSurfaceIntersection method.

 

So far, I cannot get either to work. The first one runs but gives odd values for the intersection, and the second one gives points which are on the outside edges of the part. If anyone has any code using these that does find intersection points please post part of it.

 

Thanks and regards,

 

Roger.

0 Likes
Message 5 of 8

revans1234
Enthusiast
Enthusiast

I've realised it is because the two intersecting parts are using their own coordinate systems. I need to use proxies to get the line from one and the plane from the another into a common coordinate space (i.e. the assembly) and go from there.

 

R.

0 Likes
Message 6 of 8

revans1234
Enthusiast
Enthusiast
Accepted solution

So it is sorted now.

The code is enormous and refers to other subroutines, but to help anyone with a similar problem, the following details my help.

 

Use proxies to put the line and plane in coordinate space. The line is defined by endpoints which come from the surface body edges. The plane is defined by three points. These points come from drawing an L on the plane at 2d points (0,0) (10,0) (0,10).

These points can be deleted after the routine has run.

Using geometry widely available on the net, the intersection point in 3D can be found. Draw a point at it (I used workpoints) and project to the 2D sketch of the plane.

 

R.

0 Likes
Message 7 of 8

oldgrey1
Participant
Participant

I have been wondering how to cut another part based on a mating part hole / feature. What you are doing sounds similar.

I am trying to have a face on a structural member cut by holes on a mating bolting plate - without using associativity and all those techniques.

Would you be prepared to share your code? I am not familiar with programming so I would need A - Z.

 

0 Likes
Message 8 of 8

revans1234
Enthusiast
Enthusiast

Hello oldgrey1 (interesting tagname),

 

The simple answer is the code is not simple and I would need to look at it again to explain it. What you are describing is a bit different anyway.

 

The code I have finds intersections between as parts that have been selected. One part has tabs that pass through the other- holes are drawn on the other to clear these tabs.

 

When you find the intersections between the edges of the tab part and the other you get intersection points. The code then measures the distance between every 2 points to see if they match the tab size. When it finds pais that match the width of thickness of the tab lines are drawn to find a loop. A larger loop is offset round it and then the outer loop is punched through.

 

What you describe is one part having holes on contact with a plane on another. THe code then needs to identify circles in the same plane, and draw an identical circle  (of circle with same centre but different radius) on the target plane and pucnh through that. I haven't done that bit.

 

Actually it would be very usefull to have. I have aproject which could benefit from that. If I write the code soon  I will mention it here and share it. 

 

But thanks for your interent in this thread. I appreciate it.

R.

 

0 Likes