×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Precision in input to Solidworks API macro

Precision in input to Solidworks API macro

Precision in input to Solidworks API macro

(OP)
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

RE: Precision in input to Solidworks API macro

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)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources