Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Precision in input to Solidworks API macro

Status
Not open for further replies.

macraiga

Electrical
Oct 15, 2007
4
Hi All,

I am trying to use Solidworks API to make a model which uses dimensions down on the micron level.

The problem I am having is reading in small values to the CreateArc2 and CreateLine2 functions.

this is an example of one such line:
Part.CreateArc2 LineInputArray(2), LineInputArray(3), 0, LineInputArray(4), LineInputArray(5), 0, LineInputArray(6), LineInputArray(7), 0, 1

I read into LineInputArray from a text file and the numbers go in fine however when the arc is created it rounds off the numbers lower than 100micron to 0.
Is there a way to increase the precision in the function CreateArc2????? (and CreateLine2?)

I have thought about making the whole part larger and scaling afterwards but that had its own problems.

I have changed the precision in the options and can also change the units in the document but it seems to always read from the API in metres.

I would greatly appreciate any help you could give with this.

Many thanks,
macraiga
 
Replies continue below

Recommended for you

SW should have no issues with parts of your scale. However, you probably need to use SetAddToDB.

When you use API to create sketch entities, SW doesn't automatically turn off entity and/or grid snapping or automatic relations. You will actually get different results depending on your zoom level. If you zoom out far enough before running your code, more stuff will get "rounded to zero".

Turning SetAddToDB to True turns off the snapping and should get you the result you want. However, be sure to add some error handling to turn it back to False once you get done.

-handleman, CSWP (The new, easy test)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor