when I run my code I want to select a horizontal face. But the variables I give get changed when used in SolidWorks.

Or so does it seem.

 

In the pictures you see what point does get selected in the solidworks part as a picture with a red piece that is the face I want to select.

The other picture are the numbers that the program has for the variables.

 

code:

 

Alpha = Pi/6

varcutthroughcylindercircle = 85/1000

varcylinderheight = 29/1000

varheighttopcut = 18/1000

 

dX3 = -(Sin(Alpha) * (varCutThroughCylinderCircle))

dY3 = -(Cos(Alpha) * (varCutThroughCylinderCircle))

dZ3 = -(varCylinderHeight - varHeightTopCut)

swModeldoc.Extension.SelectByID2 "", "FACE", dX3, dY3, dZ3, False, 1, Nothing, 0


Categories: API∕Macros

Comments
Last comment By: Ivan Spikmans   Thu, 14 Sep 2017 13:19:47 GMT
solidworks doesn't use/take the right values for variables

when I run my code I want to select a horizontal face. But the variables I give get changed when used in SolidWorks.

Or so does it seem.

 

In the pictures you see what point does get selected in the solidworks part as a picture with a red piece that is the face I want to select.

The other picture are the numbers that the program has for the variables.

 

code:

 

Alpha = Pi/6

varcutthroughcylindercircle = 85/1000

varcylinderheight = 29/1000

varheighttopcut = 18/1000

 

dX3 = -(Sin(Alpha) * (varCutThroughCylinderCircle))

dY3 = -(Cos(Alpha) * (varCutThroughCylinderCircle))

dZ3 = -(varCylinderHeight - varHeightTopCut)

swModeldoc.Extension.SelectByID2 "", "FACE", dX3, dY3, dZ3, False, 1, Nothing, 0

By: Ivan Spikmans  Wed, 13 Sep 2017 11:33:45 GMT
Re: solidworks doesn't use/take the right values for variables

I added the code I the main post. With the UI some parameters are filled in the rest is fixed or calculated. Its about the code in the BuildFillet function and then the third selection.

By: Ivan Spikmans  Thu, 14 Sep 2017 05:54:51 GMT
Re: solidworks doesn't use/take the right values for variables

What values do you enter into the form in order to produce the model?

By: Simon Turner  Thu, 14 Sep 2017 08:06:16 GMT
Re: solidworks doesn't use/take the right values for variables

most of the time I use from top to bottom: 93 88 85 100 80 50 0000000 and then for the value at the right I chose 15

By: Ivan Spikmans  Thu, 14 Sep 2017 09:07:26 GMT
Re: solidworks doesn't use/take the right values for variables

In BuildFillet:

 

If k = 1 then it doesn't use dX3, dY3 and dZ3

If k = 2 then dZ3 is a different value to the one you gave in your original post

By: Simon Turner  Thu, 14 Sep 2017 09:23:40 GMT
Re: solidworks doesn't use/take the right values for variables

for k = 2 the fillet works the problom is in k = 1 it wont let me select the horizontal face I want to select

By: Ivan Spikmans  Thu, 14 Sep 2017 10:25:13 GMT
Re: solidworks doesn't use/take the right values for variables

I created a 3d sketch and plotted the point you are trying to select. It lies right on the boundary between the horizontal and vertical faces.

Why not add 0.5mm onto the radius so that the point lies off of the vertical face:

 

    dx3 = -(Sin(Alpha) * (varCutThroughCylinderCircle + 0.5 / 1000))

    dy3 = -(Cos(Alpha) * (varCutThroughCylinderCircle + 0.5 / 1000))

 

That worked for me.

By: Simon Turner  Thu, 14 Sep 2017 11:34:36 GMT
Re: solidworks doesn't use/take the right values for variables

I don't know why but it still doesn't work it changes the dZ3 to 14.08 that why it changes the dX3 and dY3 because they change to other values because the select another face.

By: Ivan Spikmans  Thu, 14 Sep 2017 13:19:47 GMT
You are not authorized to view this page No results found! Suggestions: Check spelling, try a different search, or browse topics below.