Extract dimensions from part to create 2D drawing

I am very new to solidworks and the company I work for has asked me to make some applications.
The first part is that the user loads up a 3D part and what I want is to get the front face of that part, with all the dimensions of holes, widths etc and create a new 2D shape/drawing.
How would I go about doing that

Using VB.NET macros and Solid works 2010.

Thanks in advance

SolidworksApi macros
Answers 6
SF
SF 2012-07-26 Best Answer

David,

You are asking a very broad question and the SolidWorks API provides a lot of different tools that meet different needs.  Can you give us some more information about what parts you are working with, the purpose of the 2D drawing, etc.?  For example, is this resultant shape/drawing going to be done in SW or some other application?

-Tim

SF
SF 2012-07-26

Hi Tim,

There are going to be multiple parts that I will be working with, they are used to make up kitchen so there will be panels, doors, counters etc. I need to extract the dimensions, then create a new drawing (not sure if that is the correct terminology) that is 2D. All this will be done within SW.
All holes, edges etc will need to be added to this drawing. I will then need to do extra functions to this drawing (but will figure that out later)

In a nutshell what I need to do is get all the dimensions that have been used to create the drawing and put them in to variable I believe. Then I can do things when i've got that in place.

Sorry if the question is still vague. Still learning about the api and do not understand fully what solid works can do. Cheers

SF
SF 2012-07-26

I'm not familier with the SW API functions for creating drawings.  However, I did something similar to what you are talking about but instead of creating a drawing I created surface bodies.  I went that approach because in addition to 2D I needed a depth for each feature (contour, drill hole, dado, etc.).  My purpose was to create CNC tool path geometry for export to dwg/dxf.  If you have a similar purpose then I can share a few more tips and tricks with you but otherwise won't fill up this thread with info that won't help you.

-Tim

SF
SF 2012-07-27

Just had a look at what surface bodies were and this sounds exactly what I need. You say you can get the dimensions from the model/part, does this show on the surface body?
If you could teach me how to do this, and possibly how I might manage it in the api using VB.NET as I am going to try and automate the entire process with just one button it would be a great help

Thanks again

SF
SF 2012-07-27

David,

Here are the steps for creating a surface body from the edges of a particular face:

-Create a sketch on the surface of the face

-Select the face and use SketchUseEdge2 to convert the edges of the face into sketch entities

-Use FeatureExtruRefSurface2 to extrude the sketch and create a surface body

Here is some VB.Net sample code that shows how to use the SketchUseEdge2 method: http://help.solidworks.com/2012/English/api/sldworksapi/Convert_Faces_Edges_to_Sketch_Entities_Example_VB.htm

KR
KR 2012-08-02

David,

Honestly, it sounds like you need to learn more about SolidWorks before trying to tackle this automation project.  I would recommend first going through the tutorials in Help-->SolidWorks Tutorials.  Make sure you understand the basics of parts, assemblies, and drawings, and then check out the tutorial on surfaces to see if that is really what you need.  Without understanding how SolidWorks works "manually" you will really struggle in understanding how accomplish what you need with the API.

Concerning the API, regardless of what route you go, you might consider first learning how to write basic macros in VBA rather than VB.NET.  At the very least, make sure you understand how to use the API Help.  In the Videos section of my web site, Lesson 2.2 covers how to use the basics of using the API Help.  You will certainly want to know how to look up VB.NET code samples in the API Help, like the one that Tim linked to.

Finally, I would recommend you read this blog post: 7 Mistakes New SolidWorks API Programmers Make

Good luck!

Keith

Video Tutorials for the SolidWorks API