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:

Incorrect arc data


Recommended Posts

I am working on a net-hook that will analyze chains of lines and arcs that make up letters, which we use for milling embossings, and then create new geometry based off of the original geometry. In order to do this I need to iterate through these entities and run a lot of math on their data(ex. start/end point for lines; start/end point, center point, start/end angles for arcs).

 

I have the net-hook printing all of that data just to check and make sure it was capturing those values correctly and I noticed the arc center point was not correct. When I do a standard mastercam analyze entity function, it reads it correctly but not when my nethook reads it. I also noticed this only happens when the arc viewnumber is anything but 1. I tried to have my nethook change these arc view numbers before it read the data values but it just ended up moving the arcs themselves. The start and end angles are also off, as if the view its measuring in is tilted. One thing that I find strange is that the start and endpoints are correct. My only guess is that the "Data" object for the ArcGeometry class takes into account this arc viewnumber. I also have no idea what an arc view number is.

 

I guess I just need to figure out how to read this data from the correct view?

 

post-53776-0-40436900-1413481192_thumb.png

 

post-53776-0-31542200-1413481806_thumb.png

Link to comment
Share on other sites


Dim chains() As Mastercam.Database.Chain

 

chains = ChainManager.GetMultipleChains("Please select Geometery to build taper off of")

 

For Each c As Chain In chains

c.Direction = Mastercam.Database.Types.ChainDirectionType.CounterClockwise

GetPeninsulas(c)

Next


Sub GetPeninsulas(chain As Mastercam.Database.Chain) ' one letter at a time

 

Mastercam.IO.SelectionManager.UnselectAllGeometry()

 

Dim curves() As CurveGeometry = ChainManager.GetGeometryInChain(chain)

 

For Each cs As CurveGeometry In curves

If cs.GetType = GetType(ArcGeometry) Then

cs.Selected = True

cs.Commit()

End If

Next

 

Dim geo() As Geometry = SearchManager.GetSelectedGeometry

 

For Each cs As CurveGeometry In curves

Highlight(cs, True)

Next

 

End Sub


Sub Highlight(c As CurveGeometry, display As Boolean)

 

c.LineWidth = 3

c.Commit()

GraphicsManager.Repaint()

 

If display = True Then

If c.GetType = GetType(Mastercam.Curves.ArcGeometry) Then

Dim a As ArcGeometry = CType(c, ArcGeometry)

PrintArcData(a)

ElseIf c.GetType = GetType(Mastercam.Curves.LineGeometry) Then

Dim l As LineGeometry = CType(c, LineGeometry)

Dim m As Double = (l.Data.Point2.y - l.Data.Point1.y) / (l.Data.Point2.x - l.Data.Point1.x)

Dim Angle As Double = 180 - Atan(m) * 180 / PI

m = Round(m, 5)

MsgBox("Slope is: " & m & vbCrLf & "Angle is: " & Angle)

End If

Else

MsgBox(" ")

End If

 

 

c.LineWidth = 1

c.Commit()

End Sub


Sub PrintArcData(ByVal a As ArcGeometry)

 

Dim s As String = "Center Point: " & "( " & Round(a.Data.CenterPoint.x, 5) & " , " & Round(a.Data.CenterPoint.y, 5) _

& " , " & Round(a.Data.CenterPoint.z, 5) & " )" & vbCrLf

s = s + "Start Point: " & "( " & Round(a.EndPoint1.x, 5) & " , " & Round(a.EndPoint1.y, 5) & " , " & Round(a.EndPoint1.z, 5) & " )" & vbCrLf

s = s + "End Point: " & "( " & Round(a.EndPoint2.x, 5) & " , " & Round(a.EndPoint2.y, 5) & " , " & Round(a.EndPoint2.z, 5) & " )" & vbCrLf

s = s + "Radius: " & Round(a.Data.Radius, 5) & vbCrLf

s = s + "Start Angle: " & Round(a.Data.StartAngleDegrees, 5) & vbCrLf

s = s + "End Angle: " & Round(a.Data.EndAngleDegrees, 5) & vbCrLf

s = s + "Sweep Angle: " & Round(a.Data.EndAngleDegrees - a.Data.StartAngleDegrees, 5) & vbCrLf

MsgBox(s)

End Sub

 

Link to comment
Share on other sites
  Sub PrintArcData(ByVal a As ArcGeometry)

            Dim convertToWorldCoordinates = ViewManager.ConvertToWorldCoordinates(a.Data.CenterPoint, a.ViewNumber)

            Dim s As String = "Center Point:  " & "( " & Round(convertToWorldCoordinates.x, 5) & " , " & Round(convertToWorldCoordinates.y, 5) _
                              & " , " & Round(convertToWorldCoordinates.z, 5) & " )" & vbCrLf
            s = s + "Start Point:  " & "( " & Round(a.EndPoint1.x, 5) & " , " & Round(a.EndPoint1.y, 5) & " , " & Round(a.EndPoint1.z, 5) & " )" & vbCrLf
            s = s + "End Point: " & "( " & Round(a.EndPoint2.x, 5) & " , " & Round(a.EndPoint2.y, 5) & " , " & Round(a.EndPoint2.z, 5) & " )" & vbCrLf
            s = s + "Radius: " & Round(a.Data.Radius, 5) & vbCrLf
            s = s + "Start Angle: " & Round(a.Data.StartAngleDegrees, 5) & vbCrLf
            s = s + "End Angle: " & Round(a.Data.EndAngleDegrees, 5) & vbCrLf
            s = s + "Sweep Angle: " & Round(a.Data.EndAngleDegrees - a.Data.StartAngleDegrees, 5) & vbCrLf
            MsgBox(s)
        End Sub

 You need to convert the arc centres to world co-ordinates.

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...