Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations JAE on being selected by the Eng-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
Joined
Jun 17, 2014
Messages
17
Location
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
I don't know, how do it in vb, I can do it in C, Ugopen. Not so difficult.
 
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.

Part and Inventory Search

Sponsor

Back
Top