Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Circle on a plane

Status
Not open for further replies.

NirVidP

Industrial
May 10, 2010
45
I want to draw a circle on a Datum Plane.
I have the datum plane and I have the co-ordinates of the center point of circle.
I recorded the macro and every time I use a different model and the methods used in the recorded joutnals are different every time. That's what has got me confused.

How can I create the 'direction' of circle and hence the orientation of the sketch? For creating the direction of the direction of circle you need origin and a vector. What vector is that and how can I obtain it from the plane. Can I obtain this vector from the 'Normal' of the datum plane?
 
Replies continue below

Recommended for you

I think what will work out for you here is before you create your circle, place and orient your WCS onto the plane,
You will then be able to use the x-axis or y-axis of the WCS as your direction.

Format -> WCS -> Orient -> CSYS of Object -> select datum plane

junk76_cszqlp.png


Jerry J.
UGV5-NX11
 
Thank you jerry1423 for your response.
But I need VB code for this.
I think I have found the answer without need for using DATUMCsys. I am trying it out and sorting out some issues.
 
Thank you cowski, but the examples fall a little short of what I need. What I have is a DatumPlane, a point on the plane (x,y,z) - center & radius. So, to fit into one of the examples, I either have to find two more points on the face, or find the orientation matrix needed or the x and y axis vectors. That's the problem I am working on.
NB: By the way, is registration for your blog is stopped?
 
The GTAC example: nx_api5931 shows one way of getting the orientation matrix of a datum plane.

Code:
Imports System
Imports NXOpen
Imports NXOpen.UI
Imports NXOpen.Utilities
Imports NXOpen.UF

Module report_selected_datum_plane

    Dim theSession As Session = Session.GetSession()
    Dim theUFSession As UFSession = UFSession.GetUFSession()
    Dim theLW As ListingWindow = theSession.ListingWindow

    Sub Main()
        Dim thePlane As DatumPlane

        While select_a_datum_plane(thePlane ) = Selection.Response.Ok

            Dim z_vec As Double() = new Double(2){thePlane.Normal.X, thePlane.Normal.Y, thePlane.Normal.Z}
            Dim mtx As Double() = new Double(8){}
            theUFSession.mtx3.InitializeZ(z_vec, mtx)

            If Not theLW.IsOpen Then theLW.Open()
            theLW.WriteLine("Datum Plane: " & thePlane.ToString())
            theLW.WriteLine("Parent Feature: " & thePlane.Feature.GetFeatureName())
            theLW.WriteLine("Origin: " & thePlane.Origin.ToString())
            theLW.WriteLine("Normal: " & thePlane.Normal.ToString())
            theLW.WriteLine("Matrix: " & vbCrLf)
            theLW.WriteLine(String.Format("{0}, {1}, {2}", mtx(0), mtx(1), mtx(2)))
            theLW.WriteLine(String.Format("{0}, {1}, {2}", mtx(3), mtx(4), mtx(5)))
            theLW.WriteLine(String.Format("{0}, {1}, {2}", mtx(6), mtx(7), mtx(8)))

            Dim origin As Double() = new Double(2){thePlane.Origin.X, thePlane.Origin.Y, thePlane.Origin.Z}
            Dim x_vec As Double() = new Double(2){mtx(0), mtx(1), mtx(2)}
            Dim Y_vec As Double() = new Double(2){mtx(3), mtx(4), mtx(5)}
            theUFSession.Disp.Conehead(UFConstants.UF_DISP_WORK_VIEW_ONLY, origin, x_vec, 0)
            theUFSession.Disp.Conehead(UFConstants.UF_DISP_WORK_VIEW_ONLY, origin, y_vec, 0)
            theUFSession.Disp.Conehead(UFConstants.UF_DISP_WORK_VIEW_ONLY, origin, z_vec, 0)
        End While

    End Sub

    Function select_a_datum_plane(ByRef selobj As DatumPlane) As Selection.Response
        Dim ui As UI = ui.GetUI()
        Dim message As String = "Select a datum plane"
        Dim title As String = "Selection"
        Dim selectionMask(0) As Selection.MaskTriple
            With selectionMask(0)
                .Type = UFConstants.UF_datum_plane_type
                .Subtype = 0
                .SolidBodySubtype = 0
            End With
        Dim cursor As Point3d = Nothing

        Dim resp As Selection.Response = _
        ui.SelectionManager.SelectObject(message, title, _
            Selection.SelectionScope.WorkPart, _
            Selection.SelectionAction.ClearAndEnableSpecific, _
            False, False, selectionMask, selobj, cursor)

        If resp = Selection.Response.ObjectSelected Or _
           resp = Selection.Response.ObjectSelectedByName Then
            return Selection.Response.Ok
        Else
            return Selection.Response.Cancel
        End If

    End Function

    Public Function GetUnloadOption(ByVal dummy As String) As Integer
        Return Session.LibraryUnloadOption.Immediately
    End Function

End Module

www.nxjournaling.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor