Jump to content

Welcome to eMastercam

Register now to participate in the forums, access the download area, buy Mastercam training materials, post processors and more. This message will be removed once you have signed in.

Use your display name or email address to sign in:

Rotate geometry to align with selected line


Recommended Posts

I have a VBScript that creates a group of lines and arcs that are aligned with an existing line. I am in the process of converting that script into a VB NETHook. My problem is after I create that group of lines and arcs I need to align them with the existing line that was selected to position the group.

I have created the code that creates the group of lines and arcs:

    '***************************************************************************************************************************************

    '///////////////////////////// create a new group of lines & arcs ////////////////////////////////////////////////////////////////////

    '************************************************************************************************************

                 Create_line(0.0 + entity.Data.Point1.x, 0.0 + entity.Data.Point1.y, 0.0 + entity.Data.Point1.z,

                                    0.0 + entity.Data.Point1.x, 0.2622 + entity.Data.Point1.y, 0.0 + entity.Data.Point1.z, intLevel)

                Create_Arc(-0.2 + entity.Data.Point1.x, 0.2622 + entity.Data.Point1.y, 0.0 + entity.Data.Point1.z, 0.2, 360, 484.2289, intLevel)

                Create_Arc(-0.425 + entity.Data.Point1.x, 0.5929 + entity.Data.Point1.y, 0.0 + entity.Data.Point1.z, 0.2, 180, 304.2289, intLevel

                Create_line(-0.625 + entity.Data.Point1.x, 0.5929 + entity.Data.Point1.y, 0.0 + entity.Data.Point1.z,

                                    -0.625 + entity.Data.Point1.x, 0.9071 + entity.Data.Point1.y, 0.0 + entity.Data.Point1.z, intLevel)

                Create_Arc(-0.425 + entity.Data.Point1.x, 0.9071 + entity.Data.Point1.y, 0.0 + entity.Data.Point1.z, 0.2, 55.7711, 180, intLevel)

                Create_Arc(-0.2 + entity.Data.Point1.x, 1.2378 + entity.Data.Point1.y, 0.0 + entity.Data.Point1.z, 0.2, 235.7711, 360, intLevel)

                Create_line(-0.0 + entity.Data.Point1.x, 1.2378 + entity.Data.Point1.y, 0.0 + entity.Data.Point1.z,

                                    0.0 + entity.Data.Point1.x, 1.4622 + entity.Data.Point1.y, 0.0 + entity.Data.Point1.z, intLevel)

                Create_Arc(-0.2 + entity.Data.Point1.x, 1.4622 + entity.Data.Point1.y, 0.0 + entity.Data.Point1.z, 0.2, 360, 484.2289, intLevel)

                Create_Arc(-0.425 + entity.Data.Point1.x, 1.7929 + entity.Data.Point1.y, 0.0 + entity.Data.Point1.z, 0.2, 180, 304.2289, intLevel)

                Create_line(-0.625 + entity.Data.Point1.x, 1.7929 + entity.Data.Point1.y, 0.0 + entity.Data.Point1.z,

                                    -0.625 + entity.Data.Point1.x, 2.1071 + entity.Data.Point1.y, 0.0 + entity.Data.Point1.z, intLevel)

                Create_Arc(-0.425 + entity.Data.Point1.x, 2.1071 + entity.Data.Point1.y, 0.0 + entity.Data.Point1.z, 0.2, 55.7711, 180, intLevel

                Create_Arc(-0.2 + entity.Data.Point1.x, 2.4378 + entity.Data.Point1.y, 0.0 + entity.Data.Point1.z, 0.2, 235.7711, 360, intLevel)

                Create_line(0.0 + entity.Data.Point1.x, 2.4378 + entity.Data.Point1.y, 0.0 + entity.Data.Point1.z,

                                    0.0 + entity.Data.Point1.x, 2.7 + entity.Data.Point1.y, 0.0 + entity.Data.Point1.z, intLevel)

    '***************************************************************************************************************************************

    '///////////////////////////// create a new line ////////////////////////////////////////////////////////////////////

    '************************************************************************************************************

    ' sub to create a line (start x1,start y1,start z1,end x2,end y2,end z2)

    ' sub to create a line (start x1,start y1,start z1,end x2,end y2,end z2)

    Public Sub Create_line(X1point As Double, Y1point As Double, Z1point As Double, X2point As Double, Y2point As Double, Z2point As Double, intLevel As Integer)

        Dim newLine = New LineGeometry

        With newLine

            .Data.Point1 = New Point3D(X1point, Y1point, Z1point)

            .Data.Point2 = New Point3D(X2point, Y2point, Z2point)

            .Level = intLevel

            '.Color = RGB(1, 1, 240)

            .LineStyle = LineStyleType.Solid

            '.PointStyle = PointStyleType.Square

            .Commit()

        End With

        GraphicsManager.Repaint(True)

    End Sub

    '-------------------------------------------------------------------------------------------------------------------------------

    '///////////////////////////// create a new arc /////////////////////////////////////////////////////////////////////

    '*************************************************************************************************************************

    ' sub to create an arc (center x, center y, center z, radius, startangle, endangle, level)

    Public Sub Create_Arc(Center_x As Double, Center_y As Double, Center_z As Double, Rad As Double, Start_angle As Double, End_Angle As Double, intlevel As Integer)

        Dim newArc = New ArcGeometry

        With newArc

            .Data.CenterPoint.x = Center_x

            .Data.CenterPoint.y = Center_y

            .Data.CenterPoint.z = Center_z

            .Data.Radius = Rad

            .Data.StartAngleDegrees = Start_angle

            .Data.EndAngleDegrees = End_Angle

            .Level = intlevel

            '.Color = RGB(100, 255, 255)

            .LineStyle = LineStyleType.Solid

            .Commit()

        End With

        GraphicsManager.Repaint(True)

    End Sub

 

I also have the code to get the angle of the selected positional line:

 

                Dim angle = VectorManager.AngleDegrees(New Point2D(entity.Data.Point2.x - entity.Data.Point1.x, entity.Data.Point2.y - entity.Data.Point1.y))

 

What I need help with is what Mastercam API object can I use to align the group of lines and arcs to the same angle as the line the user selected to position that group of lines and arcs.

 

              Thank you

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.

Join us!

eMastercam - your online source for all things Mastercam.

Together, we are the strongest Mastercam community on the web with over 56,000 members, and our online store offers a wide selection of training materials for all applications and skill levels.

Follow us

×
×
  • Create New...