NX VB Journal - Create CenterPoint of an Arc
NX VB Journal - Create CenterPoint of an Arc
(OP)
Okay, I'm just trying to get NX to put a point at the center of an arc. Seems simple enough in concept. But it's not working for me. Here's my code (ultimately I'm just trying to get the "createpoint" method to work - the rest is just to try it out):
If I have an arc on the screen I click on it and the journal completes without errors but I don't get any new points created. Is there another method I should be using?
Thanks,
Jeff
CODE
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpenUI
Imports System.Windows.Forms
Imports System.Environment
Module report_selected_object_type_and_subtype
Sub Main
Dim s As Session = Session.GetSession()
Dim ufs As NXOpen.UF.UFSession = NXOpen.UF.UFSession.GetUFSession()
Dim selobj As NXObject
Dim arc1 as ibasecurve
dim workpart as part = s.Parts.Work
dim cpoint as point = nothing
dim kk as integer=0
Dim type As Integer
Dim subtype As Integer
Dim lw As ListingWindow = s.ListingWindow
While select_anything(selobj) = Selection.Response.Ok
ufs.Obj.AskTypeAndSubtype(selobj.Tag, type, subtype)
lw.open()
lw.writeline(selobj.tostring)
End While
arc1=ctype(selobj,ibasecurve)
cpoint=workpart.points.createpoint(arc1,smartobject.updateoption.withinmodeling)
cpoint.SetVisibility(SmartObject.VisibilityOption.Visible)
End Sub
Function select_anything(ByRef selobj As NXObject) As Selection.Response
Dim theUI As UI = ui.GetUI
Dim cursor As Point3d
Dim typeArray() As Selection.SelectionType = _
{ Selection.SelectionType.curves }
Dim resp As Selection.Response = theUI.SelectionManager.SelectObject("Select anything", _
"Select anything", _
Selection.SelectionScope.WorkPart, _
false, typeArray, 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
End Module
Imports NXOpen
Imports NXOpen.UF
Imports NXOpenUI
Imports System.Windows.Forms
Imports System.Environment
Module report_selected_object_type_and_subtype
Sub Main
Dim s As Session = Session.GetSession()
Dim ufs As NXOpen.UF.UFSession = NXOpen.UF.UFSession.GetUFSession()
Dim selobj As NXObject
Dim arc1 as ibasecurve
dim workpart as part = s.Parts.Work
dim cpoint as point = nothing
dim kk as integer=0
Dim type As Integer
Dim subtype As Integer
Dim lw As ListingWindow = s.ListingWindow
While select_anything(selobj) = Selection.Response.Ok
ufs.Obj.AskTypeAndSubtype(selobj.Tag, type, subtype)
lw.open()
lw.writeline(selobj.tostring)
End While
arc1=ctype(selobj,ibasecurve)
cpoint=workpart.points.createpoint(arc1,smartobject.updateoption.withinmodeling)
cpoint.SetVisibility(SmartObject.VisibilityOption.Visible)
End Sub
Function select_anything(ByRef selobj As NXObject) As Selection.Response
Dim theUI As UI = ui.GetUI
Dim cursor As Point3d
Dim typeArray() As Selection.SelectionType = _
{ Selection.SelectionType.curves }
Dim resp As Selection.Response = theUI.SelectionManager.SelectObject("Select anything", _
"Select anything", _
Selection.SelectionScope.WorkPart, _
false, typeArray, 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
End Module
If I have an arc on the screen I click on it and the journal completes without errors but I don't get any new points created. Is there another method I should be using?
Thanks,
Jeff





RE: NX VB Journal - Create CenterPoint of an Arc
I knew I shoulda waited until I gave it one more kick at the can!
RE: NX VB Journal - Create CenterPoint of an Arc
CODE
'ufs.Obj.AskTypeAndSubtype(selobj.Tag, type, subtype)
'lw.writeline(selobj.tostring)
arc1=ctype(selobj,ibasecurve)
cpoint=workpart.points.createpoint(arc1,smartobject.updateoption.withinmodeling)
cpoint.SetVisibility(SmartObject.VisibilityOption.Visible)
'remove parameters to create dumb point, keep them to create smart point (will follow the arc, but is not a point feature)
'cpoint.RemoveParameters()
End While
CODE
'ufs.Obj.AskTypeAndSubtype(selobj.Tag, type, subtype)
'lw.writeline(selobj.tostring)
arc1=ctype(selobj,ibasecurve)
cpoint=workpart.points.createpoint(arc1,smartobject.updateoption.withinmodeling)
cpoint.SetVisibility(SmartObject.VisibilityOption.Visible)
'remove parameters to create dumb point, keep them to create smart point (will follow the arc, but is not a point feature)
'cpoint.RemoveParameters()
End If
www.nxjournaling.com
RE: NX VB Journal - Create CenterPoint of an Arc
www.nxjournaling.com
RE: NX VB Journal - Create CenterPoint of an Arc
CODE
'ufs.Obj.AskTypeAndSubtype(selobj.Tag, type, subtype)
'lw.writeline(selobj.tostring)
arc1=ctype(selobj,ibasecurve)
cpoint=workpart.points.createpoint(arc1,smartobject.updateoption.withinmodeling)
cpoint.SetVisibility(SmartObject.VisibilityOption.Visible)
'remove parameters to create dumb point, keep them to create smart point (will follow the arc, but is not a point feature)
'cpoint.RemoveParameters()
'*** start of code to create point feature
Dim nullFeatures_Feature As Features.Feature = Nothing
Dim pointFeatureBuilder1 As Features.PointFeatureBuilder
pointFeatureBuilder1 = workPart.BaseFeatures.CreatePointFeatureBuilder(nullFeatures_Feature)
pointFeatureBuilder1.Point = cpoint
'nXObject1 will be a reference to your new point feature
Dim nXObject1 As NXObject
nXObject1 = pointFeatureBuilder1.Commit()
pointFeatureBuilder1.Destroy()
'*** end of code to create point feature
End if
www.nxjournaling.com