Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Create center points from many arcs by selecting all 1

Status
Not open for further replies.

zizacad

Automotive
Jun 17, 2014
17
0
0
BR
Hi everyone, I came across with this thread (NX VB Journal - Create CenterPoint of an Arc) about create points in a previously created arc but it´s necessary select one by one, how can I do it by selecting all circles at the same time, is that possible? I´d like to create spheres on these points as well. Thanks in advance! (I´m working on NX-9.0)
 
 http://files.engineering.com/getfile.aspx?folder=888ed43f-d654-482d-8202-f7e9d772dd30&file=circles.PNG
Replies continue below

Recommended for you

Here's how you do with VB code that calls SNAP functions. If you wanted to call NX/Open functions, instead, the basic idea would be the same, but the code would be somewhat longer.

Code:
Option Infer On
Imports Snap, Snap.Create, Snap.UI

Public Class MyProgram

    Public Shared Sub Main()

      ' Create a selection dialog, and allow selection of multiple arcs
      Dim dialog = Selection.SelectObject("Select arcs")
      dialog.SetCurveFilter(Snap.NX.ObjectTypes.Type.Arc)
      dialog.AllowMultiple = True

      ' Display the dialog and get a result
      Dim result = dialog.Show()

      ' Cycle through the selected arcs
      If result.Response <> Response.Cancel And result.Response <> Response.Back Then
         For Each obj In result.Objects
            Dim arc As NX.Arc = CType(obj, Snap.NX.Arc)    ' Cast to type Arc
            Dim center As Position = arc.Center            ' Get center
            Point(center)                                  ' Create point
            Sphere(center, arc.Diameter)                   ' Create sphere
         Next
      End If

    End Sub

End Class

The code creates spheres, too, and the diameter of each sphere is set equal to the diameter of the corresponding arc. If that's not what you want, the modifications should be quite simple.
 
Hi Bubbak, that's exactly what I need with exception the spheres but it´s no problem, thank you so much for help me, it will be very useful to me, I really appreciate your help!
 
Status
Not open for further replies.
Back
Top