Please Help!!! - Rotate new Workplane along a default Axis With API

Please Help!!! - Rotate new Workplane along a default Axis With API

jpchaisson
Advocate Advocate
1,909 Views
8 Replies
Message 1 of 9

Please Help!!! - Rotate new Workplane along a default Axis With API

jpchaisson
Advocate
Advocate

How do you create a new Workplane from a Defualt Plane and rotate it along a default Axis?

 

I am new to API and trying to create workplanes and rotate them along a Axis.

 

Im trying to use "AddByPlaneAndOffset" is this the right method?

0 Likes
1,910 Views
8 Replies
Replies (8)
Message 2 of 9

Ralf_Krieg
Advisor
Advisor

Hi

 

No, AddByPlaneAndOffset allows only a plane parallel to the source plane. Use SetByLinePlaneAndAngle instead.


R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes
Message 3 of 9

jpchaisson
Advocate
Advocate

can you show me a example of using that method?

0 Likes
Message 4 of 9

jpchaisson
Advocate
Advocate

ok i have it working, but my angle isnt coming out right. how do i set the angle as a Object?

0 Likes
Message 5 of 9

Ralf_Krieg
Advisor
Advisor

Hi

 

Sorry, couldn't provide the example at work. Now at home I'm too late.

 

The angle, if provided as numeric value without dimension is interpreted as radiant !

 

From developers help:

 

Input Variant that defines the offset angle of the work plane from the input plane. This can be a numeric value or a string. The offset angle of a work plane is always defined by a parameter. When a new work plane is created, the parameter is automatically created. If a numeric value is supplied the new parameter is set to the value specified and the value is always in radians. If a string is supplied it is used as the expression for the newly created parameter and will be interpreted the same as if the user entered it in a dialog. This means if a value is specified without a unit qualifier it will default to the current document length unit. The following is a valid entry for the angle, assuming the parameter d2 already exists and defines an angle, 'd2 + 10 deg'. The positive angle direction is computed by crossing the axis vector with the plane normal vector.

R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes
Message 6 of 9

jpchaisson
Advocate
Advocate

thank you for responding, i think i understand what you are saying heres my code for a more visual.

 

 

       

Dim oPartDoc As PartDocument  

Dim oPartCompDef As PartComponentDefinition       

Dim BaseXY As WorkPlane       

Dim AxisX As WorkAxis      

Dim oANG1 As Double

 

           oPartDoc = oApp.ActiveDocument

        oPartCompDef = oPartDoc.ComponentDefinition

        BaseXY = oPartCompDef.WorkPlanes.Item(3)

        AxisX = oPartCompDef.WorkAxes.Item(1)

        oANG1 = "30"

 

        oPartCompDef.WorkPlanes.AddByLinePlaneAndAngle(AxisX, BaseXY, oANG1)

 

what am i doing wrong my workplane ends up being a 2.xxxxxxx deg angle???

0 Likes
Message 7 of 9

Ralf_Krieg
Advisor
Advisor

Hello

 

Try

 

Dim oANG1 As String
oANG1 = "30 grd"

 

Your code means an angle of 30 radiant = 1718,8733853925°.


R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes
Message 8 of 9

jpchaisson
Advocate
Advocate

Thank you so much its working great now.

 

can you explain what the "grd" means ?

 

 

0 Likes
Message 9 of 9

Ralf_Krieg
Advisor
Advisor

Hi

 

"grd" means just grad or degrees or ° and is the unit of angle value. Take a look at your fx-Parameters after creating your workplane and the new parameter for the angle.


R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes