Submitted by 218156 on Tue, 01/21/2020 - 07:54
Forums:
Hello All,
Below Code
For Each myPoint As Point in Workpart.Points
myPoint.Highlight
Next
Is working In Individual File, but when Points are created in MasterModel file, these points are not selecting In Drawing file for note creation / Highlighting In Teamcenter, Can you please Help Me, Thanks In Advance
re: point selection
There are a few different ways to get at these points, depending on what you need to do. One way would be to use .CycleObjsInPart, looking for all the points in the drawing (or assembly) file. Alternately, you could iterate through the point collection of the component part and use .FindOccurrence to get the corresponding occurrence point in the assembly file.
If you want the user to interactively select points, the selection routine will need to allow selection from anywhere in the assembly. Also, if you are selecting the points from drawing views (in the drafting application), the selection option may need to be changed to "any view".
What version of NX are you using? What does your intended work flow look like? Do you want the points selected automatically by the journal or should the user interactively select points as input for further processing?
Thanks For quick reply
Thanks For quick reply
Below Is the Code That I have recorded in NX 11 and modified According to my requirement,
In which it will Identify all the points in user specified layer and view,
then creates (*) symbol as note on these points,
This is working fine for individual file say part1(where model and drawing on same file),
but not working in teamcentre where part file and drawing file are different
(part file part1 is called in drawing file (say part1.dwg) as component,
I need this to work on drawing file, can you please help, Thanks in Advance
Imports System
Imports NXOpen
Module NXJournal
Sub Main (ByVal args() As String)
Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()
Dim workPart As NXOpen.Part = theSession.Parts.Work
Dim j As Integer
j=InputBox("Enter Layer Number Of Points")
Dim ViewName As String
ViewName=InputBox("Enter View Name From Part Nevigator")
For Each point1 As Point In workPart.Points
IF point1.Layer = j then
Dim nullNXOpen_Annotations_SimpleDraftingAid As NXOpen.Annotations.SimpleDraftingAid = Nothing
Dim draftingNoteBuilder1 As NXOpen.Annotations.DraftingNoteBuilder = Nothing
draftingNoteBuilder1 = workPart.Annotations.CreateDraftingNoteBuilder(nullNXOpen_Annotations_SimpleDraftingAid)
draftingNoteBuilder1.Origin.SetInferRelativeToGeometry(True)
draftingNoteBuilder1.Origin.Plane.PlaneMethod = NXOpen.Annotations.PlaneBuilder.PlaneMethodType.XyPlane
draftingNoteBuilder1.Origin.Anchor = NXOpen.Annotations.OriginBuilder.AlignmentPosition.MidCenter
Dim text2(0) As String
text2(0) = "*"
draftingNoteBuilder1.Text.TextBlock.SetText(text2)
'Dim point1 As NXOpen.Point = CType(workPart.Points.FindObject("ENTITY 2 3 1"), NXOpen.Point)
Dim nullNXOpen_Xform As NXOpen.Xform = Nothing
Dim point2 As NXOpen.Point = Nothing
point2 = workPart.Points.CreatePoint(point1, nullNXOpen_Xform, NXOpen.SmartObject.UpdateOption.AfterModeling)
Dim assocOrigin1 As NXOpen.Annotations.Annotation.AssociativeOriginData = Nothing
assocOrigin1.OriginType = NXOpen.Annotations.AssociativeOriginType.AtAPoint
Dim baseView1 As NXOpen.Drawings.DraftingView = CType(workPart.DraftingViews.FindObject(ViewName), NXOpen.Drawings.DraftingView)
assocOrigin1.AssociatedView = baseView1
assocOrigin1.AssociatedPoint = point2
draftingNoteBuilder1.Origin.SetAssociativeOrigin(assocOrigin1)
Dim nXObject1 As NXOpen.NXObject = Nothing
nXObject1 = draftingNoteBuilder1.Commit()
draftingNoteBuilder1.Destroy()
End If
Next
End Sub
End Module
re: points in drawing
If you have a reference to a view, you can use .AskVisibleObjects to process the objects in the view. If you are only interested in points, you can check the object type and process it accordingly.
Quick example:
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpenUI
Module Module151
Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession()
Dim ui As UI = UI.GetUI()
Sub Main()
Dim lw As ListingWindow = theSession.ListingWindow
lw.Open()
Dim dwgview As Drawings.DraftingView = Nothing
select_a_drawing_member_view(dwgview)
For Each tempObj As DisplayableObject In dwgview.AskVisibleObjects
lw.WriteLine("object type: " & tempObj.GetType.ToString)
lw.WriteLine("object layer: " & tempObj.Layer.ToString)
If TypeOf (tempObj) Is Point Then
Dim myPt As Point = tempObj
lw.WriteLine("coordinates: " & myPt.Coordinates.ToString)
End If
lw.WriteLine("")
Next
lw.Close()
End Sub
Function select_a_drawing_member_view(ByRef dwgview As Drawings.DraftingView)
Dim mask(0) As Selection.MaskTriple
With mask(0)
.Type = UFConstants.UF_view_type
.Subtype = UFConstants.UF_all_subtype
.SolidBodySubtype = 0
End With
Dim cursor As Point3d = Nothing
Dim vw As View = Nothing
Dim resp As Selection.Response =
UI.SelectionManager.SelectObject("Select a drawing member view",
"Select a drawing member view",
Selection.SelectionScope.AnyInAssembly,
Selection.SelectionAction.ClearAndEnableSpecific,
False, False, mask, vw, cursor)
If resp = Selection.Response.ObjectSelected Or
resp = Selection.Response.ObjectSelectedByName Then
dwgview = CType(vw, Drawings.DraftingView)
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 when the NX session terminates
'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination
'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
hi, Do you have any example
hi, Do you have any example of selecting the drafting points in a view either manually using a selection window or all visible points in a drafting view and get their object names.
1.)For creating View Dependent edit, i need to select some of the drafting view points. My erroneous code for VDE is available in this link: http://nxjournaling.com/comment/5784#comment-5784
2.) for creating Auto notes for the points(with notes text as point object name )on all the views.
I have tried doing selection of drafting points. But i'm not so successful in doint it with my very limited knowledge of the NX journaling.
Balaji
This Is What I was looking
This Is What I was looking for and it is working, Thank you So Much