Submitted by BHAVANSH on Sun, 09/03/2023 - 17:38
Forums:
Is there anything in the API that can be used to list out all the control points(intersection points) of each centermark on the drawing view?
For example:
A drawing view has 10 holes,
5 are at H1, 5 are at H2,
there are 2 centermarks C1 and C2,
C1 has all the holes at H1 and C2 has all the holes at H2.
For C1 and C2 all the centermark control/intersection points represent hole centers.
Anything that can be used to list out both control points.
re: centermark control points
Is this in reference to a "bolt circle" style of center line where each hole location has a mark, but they are all contained in a single center mark object?
Re: Re: Centermark Control Points
Hello,
Thanks for looking into this.
I am not sure what a "bolt circle" is, I describe it as a "circle/arc center" or "crosshair" --but below is how to create it.
1. In modelling create a body with multiple holes at same height.
2. In drafting create a side view(normal to the hole axis).
3. After placing the view, Home Ribbon> Annotations Ribbon Group> Center Mark.
4. In Center mark dialog box uncheck "create multiple centermark".
5. Select all the hole edges/faces. (be consistent with selection/either all edges or all faces).
5. It should create a chain of connected + symbols.
Each intersection of that chained + symbol is a control point, I am looking to extract those co-ordinates.
Thanks
BH
re: centermark control points
The code below will allow you to select a centermark and will report some of its properties (including the locations on the model). It is a slight variation on the code found here:
https://community.sw.siemens.com/s/question/0D54O00007hC7eTSAS/find-cent...
If you need the locations on the drawing sheet, you can use the MapModelToDrawing method to convert the model coordinates to drawing coordinates.
'NXJournaling.com
'September 6, 2023
'Allow the user to select a centerline, report the centerpoint location(s).
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Module Module2
Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession()
Dim theUI As UI = UI.GetUI()
Dim lw As ListingWindow = theSession.ListingWindow
Sub Main()
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "report centerline")
lw.Open()
Dim myCenterline As Annotations.Centerline = Nothing
Do While SelectCenterLine("select centerline", myCenterline) = Selection.Response.Ok
Dim handle As String = Nothing
Dim fileData As String = Nothing
Dim ID As UInteger = 0
Dim version As UInteger = 0
handle = theUfSession.Tag.AskHandleOfTag(myCenterline.Tag)
theUfSession.Tag.DecomposeHandle(handle, fileData, ID, version)
'lw.WriteLine("center line ID: " & ID.ToString)
For i As Integer = 1 To myCenterline.NumberOfAssociativities
Dim myAssociativity As Annotations.Associativity = Nothing
myAssociativity = myCenterline.GetAssociativity(i)
lw.WriteLine("associativity: " & i.ToString)
lw.WriteLine(myAssociativity.FirstObject.GetType.ToString)
lw.WriteLine("isOccurrence: " & myAssociativity.FirstObject.IsOccurrence.ToString)
lw.WriteLine("point option: " & myAssociativity.PointOption.ToString)
'lw.WriteLine("first definition point: " & myAssociativity.FirstDefinitionPoint.ToString)
lw.WriteLine("pick point (model): " & myAssociativity.PickPoint.ToString)
If myAssociativity.FirstObject.IsOccurrence Then
lw.WriteLine("owning component: " & myAssociativity.FirstObject.OwningComponent.DisplayName)
Else
End If
If TypeOf (myAssociativity.FirstObject) Is Drawings.DraftingCurve Then
Dim parentCount As Integer
Dim parents() As Tag = Nothing
theUfSession.Draw.AskDraftingCurveParents(myAssociativity.FirstObject.Tag, parentCount, parents)
'lw.WriteLine("parent count: " & parentCount.ToString)
For Each temp As Tag In parents
Dim tempObj As NXObject = Utilities.NXObjectManager.Get(temp)
'lw.WriteLine("parent type: " & tempObj.GetType.ToString)
'lw.WriteLine("is occurrence: " & tempObj.IsOccurrence.ToString)
If tempObj.IsOccurrence Then
lw.WriteLine("owning component: " & tempObj.OwningComponent.DisplayName)
Else
lw.WriteLine("owning part: " & tempObj.OwningPart.Leaf)
End If
Next
End If
lw.WriteLine("")
Next
Loop
lw.Close()
End Sub
Function SelectCenterLine(ByVal prompt As String, ByRef selObj As Annotations.Centerline) As Selection.Response
Dim theUI As UI = UI.GetUI
Dim title As String = "Select a centerline"
Dim includeFeatures As Boolean = False
Dim keepHighlighted As Boolean = False
Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific
Dim cursor As Point3d
Dim scope As Selection.SelectionScope = Selection.SelectionScope.WorkPart
Dim selectionMask_array(1) As Selection.MaskTriple
With selectionMask_array(0)
.Type = UFConstants.UF_drafting_entity_type
.Subtype = UFConstants.UF_draft_linear_cntrln_subtype
End With
With selectionMask_array(1)
.Type = UFConstants.UF_drafting_entity_type
.Subtype = UFConstants.UF_draft_cyl_cntrln_subtype
End With
Dim resp As Selection.Response = theUI.SelectionManager.SelectTaggedObject(prompt,
title, scope, selAction,
includeFeatures, keepHighlighted, selectionMask_array,
selObj, cursor)
If resp = Selection.Response.ObjectSelected OrElse 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
'Unloads the image immediately after execution within NX
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
End Function
End Module