Showing results for 
Search instead for 
Do you mean 
Reply

Create a meshpoint from a existing point

I have created a point (type is NXOpen::Point *) in FEM, now I want to create a MeshPoint using this point, but  there is a problem, the dialog shows "Selected point does not have any underlying geometry ".

捕获.JPG

Code (NX Open C++):

NXOpen::CAE::MeshPointExistingPointBuilder *meshPointBuilder = workFemPart->MeshPoints()->CreateMeshpointExistingPointBuilder();
meshPointBuilder->ExistingPoint()->Add(point);
NXOpen::NXObject* nxObject=meshPointBuilder->Commit();
meshPointBuilder->Destroy();

 

 Is there anyone who can help me solve this ?

Best regards!

3 REPLIES

Re: Create a meshpoint from a existing point

Hello ZhuZhenwei,

 

I think your problem is not related to NXopen, but a general NX behaviour.

A mesh point is connected to geomety, and makes sure that a node is generated on that mesh point and associative to the geometry. Your point is space is not a geometry and also not associated to any geometry. Therefore you cannot create a mesh point on that point.

 

I hope this makes it clear to you.

 

Regards,

Frederik 

Re: Create a meshpoint from a existing point

Hello Frederik ,

Thanku for your answer!

But how to create a geometry point with the cordinates?

Best regards!

ZhuZhenwei

      

Re: Create a meshpoint from a existing point

Hello ZhuZhenwei,

 

Below I have pasted the code. In this code there are two subs. One creates a yellow point in space at the given coordinates (which is in the example Main). The other sub does the same, but takes a NXOpen Point3D as input instead of the coordinates as doubles.

If you don't want the point to be yellow, you will have to remove this piece of code.

 

 

Hope this helps

Frederik

 

 

 

' NX 10.0.1.4
' Journal created by frederik.vanhee on Fri Jul 31 09:58:00 2015 W. Europe Daylight Time
' To be run in .fem environment
Option Strict On
Imports System
Imports NXOpen

Module NXJournal
    Sub Main()
			'Call here your function.
			'Example:
			CreateYellowPointOnCoordinate(0.1, 0.2, 0.3)
		
    End Sub



    ''' <summary>
    ''' This sub creates a yellow point in space on the coordinates passed in the sub,
    ''' </summary>
    ''' <param name="X_Coordinate">Global X coordinate [mm] of the point to be created</param>
    ''' <param name="Y_Coordinate">Global Y coordinate [mm] of the point to be created</param>
    ''' <param name="Z_Coordinate">Global Z coordinate [mm] of the point to be created</param>
    ''' <remarks></remarks>
    Sub CreateYellowPointOnCoordinate(ByVal X_Coordinate As Double, ByVal Y_Coordinate As Double, ByVal Z_Coordinate As Double)

        Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()
        Dim workFemPart As NXOpen.CAE.FemPart = CType(theSession.Parts.BaseWork, NXOpen.CAE.FemPart)

        Dim displayFemPart As NXOpen.CAE.FemPart = CType(theSession.Parts.BaseDisplay, NXOpen.CAE.FemPart)

        ' ----------------------------------------------
        '   Menu: Insert->Model Preparation->Point...
        ' ----------------------------------------------
        Dim unit1 As NXOpen.Unit = CType(workFemPart.UnitCollection.FindObject("MilliMeter"), NXOpen.Unit)

        Dim scalar1 As NXOpen.Scalar
        scalar1 = workFemPart.Scalars.CreateScalar(X_Coordinate, NXOpen.Scalar.DimensionalityType.None, NXOpen.SmartObject.UpdateOption.AfterModeling)
        'scalar1 = workFemPart.Scalars.CreateScalarExpression(expression1, NXOpen.Scalar.DimensionalityType.None, NXOpen.SmartObject.UpdateOption.AfterModeling)

        Dim scalar2 As NXOpen.Scalar
        scalar2 = workFemPart.Scalars.CreateScalar(Y_Coordinate, NXOpen.Scalar.DimensionalityType.None, NXOpen.SmartObject.UpdateOption.AfterModeling)
        'scalar2 = workFemPart.Scalars.CreateScalarExpression(expression2, NXOpen.Scalar.DimensionalityType.None, NXOpen.SmartObject.UpdateOption.AfterModeling)

        Dim scalar3 As NXOpen.Scalar
        scalar3 = workFemPart.Scalars.CreateScalar(Z_Coordinate, NXOpen.Scalar.DimensionalityType.None, NXOpen.SmartObject.UpdateOption.AfterModeling)
        'scalar3 = workFemPart.Scalars.CreateScalarExpression(expression3, NXOpen.Scalar.DimensionalityType.None, NXOpen.SmartObject.UpdateOption.AfterModeling)

        Dim point1 As NXOpen.Point
        point1 = workFemPart.Points.CreatePoint(scalar1, scalar2, scalar3, NXOpen.SmartObject.UpdateOption.AfterModeling)

        point1.SetVisibility(NXOpen.SmartObject.VisibilityOption.Visible)

        Dim id1 As NXOpen.Session.UndoMarkId
        id1 = theSession.NewestVisibleUndoMark

        Dim nErrs1 As Integer
        nErrs1 = theSession.UpdateManager.DoUpdate(id1)

        ' ----------------------------------------------
        '   Make Point Yellow (color code 6)
        ' ----------------------------------------------
        Dim displayModification1 As NXOpen.DisplayModification
        displayModification1 = theSession.DisplayManager.NewDisplayModification()

        displayModification1.NewColor = 6

        Dim objects1(0) As NXOpen.DisplayableObject
        objects1(0) = point1

        displayModification1.Apply(objects1)

        displayModification1.Dispose()

    End Sub



    ''' <summary>
    ''' This sub creates multiple yellow points in space on the coordinates passed in the sub,
    ''' </summary>
    ''' <param name="Nodes">Array of CAE.Point3d [mm] of the points to be created</param>
    ''' <remarks></remarks>
    Sub CreateYellowPointsOnCoordinates(Nodes() As Point3d)
        Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()
        Dim workFemPart As NXOpen.CAE.FemPart = CType(theSession.Parts.BaseWork, NXOpen.CAE.FemPart)

        Dim displayFemPart As NXOpen.CAE.FemPart = CType(theSession.Parts.BaseDisplay, NXOpen.CAE.FemPart)

        Dim unit1 As NXOpen.Unit = CType(workFemPart.UnitCollection.FindObject("MilliMeter"), NXOpen.Unit)

        Dim Points(Nodes.Length - 1) As Point

        For ii As Integer = 0 To Nodes.Length - 1
            Points(ii) = workFemPart.Points.CreatePoint(Nodes(ii))
            Points(ii).SetVisibility(NXOpen.SmartObject.VisibilityOption.Visible)
        Next

        Dim displayModification1 As NXOpen.DisplayModification
        displayModification1 = theSession.DisplayManager.NewDisplayModification()

        displayModification1.NewColor = 6

        displayModification1.Apply(Points)

        displayModification1.Dispose()

    End Sub


    Public Function GetUnloadOption(ByVal dummy As String) As Integer

        'Unloads the image when the NX session terminates
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination

        '----Other unload options-------
        'Unloads the image immediately after execution within NX
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

        'Unloads the image explicitly, via an unload dialog
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly
        '-------------------------------

    End Function

End Module