Quantcast
Channel: NX Journaling - Journaling / NXOpen API
Viewing all 783 articles
Browse latest View live

Routing Control Points coordinates

$
0
0

I'm really new in NX Open.

I'd like to create a code where the user is able to select routing control points and get printed individual XYZ coordinates.

My idea was to create a points matrix with the selected control points. The coordinates Will be show up in a tabulated format in groups every time user clics "OK"

Does anybody have a similar code I can use to modify?

I realy appreciate your help.


2D Centerline of Slot hole

$
0
0

Hi, I'm wondering how can I get two 2d centerlines
of Slot Hole (2 selected arcs and 2 selected lines)

Thanks for any suggestions

Auto label creation for Drafting Points

$
0
0

Hello All,

Below journal creates label for the visible drafting points as the same name as that of the point objects.

Label positioning is based on the cursor position selection.
Could someone help with the positioning of the point labels based on the WCS.

' NX 12.0.1.7' Journal created by Balaji_Sampath03 on Mon Jun 29 20:50:40 2020 India Standard Time 
'**************************************************************************************'This Macro creates the Point Label for all visible drafting points in the view'All the points are labeled based on the 3D point object names'This macro does not have any exception to catch any errors and is not tested extensively'Location of the point labels are selected by the cursor picking a position on the screen'*************************************************************************************** 
Option Strict Off
 
Imports System
Imports System.Collections.GenericImports NXOpen
Imports NXOpen.AnnotationsImports NXOpen.UIImports NXOpen.UFImports NXOpen.Utilities 
Module ViewDepEdit
 
Sub Main (ByVal args()AsString) 
Dim theSession As Session = Session.GetSession()Dim theUfSession As UFSession = UFSession.GetUFSession()Dim workPart As Part = theSession.Parts.WorkDim displayPart As Part = theSession.Parts.DisplayDim theDraftView As Drawings.DraftingViewDim ptsPoints AsNew List(Of Point)Dim ptsNames AsNew List(OfString)Dim ptsCount AsInteger="0"Dim tempName AsString=Nothing 
Dim lw As ListingWindow = theSession.ListingWindow 
Do Until SelDraftingView("select drafting view", theDraftView)= Selection.Response.Cancel 
''''''''''''''''''''''''''''''''''Get a location for Point label'''''''''''''''''''''''''''''''''Dim cursor As Point3d
Dim response As Selection.DialogResponse= SelectScreenPos(cursor)If response <> Selection.DialogResponse.PickThenReturnEndIf 
ForEach tempObj As DisplayableObject In theDraftView.AskVisibleObjectsIfTypeOf tempObj Is Point Then
		ptsPoints.Add(tempObj)
		tempName = tempObj.Name
		ptsNames.Add(tempName)
		tempObj.HighlightEndIfNext 
For i AsInteger=0to ptsPoints.Count-1
	ptsCount +=1 
	Dim markId1 As NXOpen.Session.UndoMarkId=Nothing
	markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Start") 
	Dim nullNXOpen_Annotations_SimpleDraftingAid As NXOpen.Annotations.SimpleDraftingAid=NothingDim draftingNoteBuilder1 As NXOpen.Annotations.DraftingNoteBuilder=NothingDim leaderData1 As NXOpen.Annotations.LeaderData=NothingDim symbolscale1 AsDouble=NothingDim symbolaspectratio1 AsDouble=Nothing 
		Dim text1(0)AsString
		text1(0)= ptsNames.Item(i) 
	draftingNoteBuilder1 = workPart.Annotations.CreateDraftingNoteBuilder(nullNXOpen_Annotations_SimpleDraftingAid)
	draftingNoteBuilder1.Origin.SetInferRelativeToGeometry(True)
	draftingNoteBuilder1.Origin.Anchor= NXOpen.Annotations.OriginBuilder.AlignmentPosition.MidCenter
	draftingNoteBuilder1.Text.TextBlock.SetText(text1)
	draftingNoteBuilder1.TextAlignment= NXOpen.Annotations.DraftingNoteBuilder.TextAlign.Belowbottom
	draftingNoteBuilder1.Origin.Plane.PlaneMethod= NXOpen.Annotations.PlaneBuilder.PlaneMethodType.XyPlane
	draftingNoteBuilder1.Origin.SetInferRelativeToGeometry(True) 
	leaderData1 = workPart.Annotations.CreateLeaderData()
	leaderData1.StubSize=5.0
	leaderData1.Arrowhead= NXOpen.Annotations.LeaderData.ArrowheadType.FilledArrow
	leaderData1.VerticalAttachment= NXOpen.Annotations.LeaderVerticalAttachment.Center 
	draftingNoteBuilder1.Leader.Leaders.Append(leaderData1) 
	leaderData1.StubSide= NXOpen.Annotations.LeaderSide.Inferred
	leaderData1.StubSize=2 
	symbolscale1 = draftingNoteBuilder1.Text.TextBlock.SymbolScale
	symbolaspectratio1 = draftingNoteBuilder1.Text.TextBlock.SymbolAspectRatio 
	Dim baseView1 As NXOpen.Drawings.DraftingView= theDraftView
	Dim draftingPoint1 As NXOpen.Drawings.DraftingPoint= ptsPoints.Item(i) 
	Dim point1_1 As NXOpen.Point3d=New NXOpen.Point3d(0.0, 0.0, 0.0)
	point1_1 = ptsPoints(i).CoordinatesDim point2_1 As NXOpen.Point3d=New NXOpen.Point3d(0.0, 0.0, 0.0)
	point2_1 = ptsPoints(i).Coordinates 
	Dim nullNXOpen_View As NXOpen.View=Nothing
	leaderData1.Leader.SetValue(NXOpen.InferSnapType.SnapType.Exist, draftingPoint1, baseView1, point1_1, Nothing, nullNXOpen_View, point2_1) 
	'Jog position relocated or jog removed
	leaderData1.Jogs.Clear() 
	Dim assocOrigin1 As NXOpen.Annotations.Annotation.AssociativeOriginData=Nothing
	assocOrigin1.OriginType= NXOpen.Annotations.AssociativeOriginType.Drag
	assocOrigin1.View= nullNXOpen_View
	assocOrigin1.ViewOfGeometry= nullNXOpen_View
	Dim nullNXOpen_Point As NXOpen.Point=Nothing 
	assocOrigin1.PointOnGeometry= nullNXOpen_Point
	Dim nullNXOpen_Annotations_Annotation As NXOpen.Annotations.Annotation=Nothing 
	assocOrigin1.VertAnnotation= nullNXOpen_Annotations_Annotation
	assocOrigin1.HorizAnnotation= nullNXOpen_Annotations_Annotation
	assocOrigin1.AlignedAnnotation= nullNXOpen_Annotations_Annotation
	assocOrigin1.VertAlignmentPosition= NXOpen.Annotations.AlignmentPosition.TopLeft
	assocOrigin1.HorizAlignmentPosition= NXOpen.Annotations.AlignmentPosition.TopLeft
	assocOrigin1.DimensionLine=0
	assocOrigin1.AssociatedView= nullNXOpen_View
	assocOrigin1.AssociatedPoint= ptsPoints(i)
	assocOrigin1.OffsetAnnotation= nullNXOpen_Annotations_Annotation
	assocOrigin1.OffsetAlignmentPosition= NXOpen.Annotations.AlignmentPosition.TopLeft
	assocOrigin1.XOffsetFactor=0.0
	assocOrigin1.YOffsetFactor=0.0
	assocOrigin1.StackAlignmentPosition= NXOpen.Annotations.StackAlignmentPosition.Above 
	Dim label_ABS_Loc As NXOpen.Point3d=New NXOpen.Point3d(0.0, 0.0, 0.0)
	label_ABS_Loc = ptsPoints(i).Coordinates 
'*******************'Convert ABS to WCS'******************* 
	'Dim label_WCS_Loc As NXOpen.Point3d = Nothing'Dim pt1(2), pt2(2) As Double 
	'pt1(0) = ptsPoints(i).Coordinates.X'pt1(1) = ptsPoints(i).Coordinates.Y'pt1(2) = ptsPoints(i).Coordinates.Z 
	'theUfSession.Csys.MapPoint(UFConstants.UF_CSYS_ROOT_COORDS, pt1, _'			UFConstants.UF_CSYS_ROOT_WCS_COORDS, pt2) 
	'label_WCS_Loc.X = pt2(0)'label_WCS_Loc.Y = pt2(1)'label_WCS_Loc.Z = pt2(2) 
'*****************************************'Select Label position upon Cursor picking'***************************************** 
	draftingNoteBuilder1.Origin.Origin.SetValue(Nothing, nullNXOpen_View, cursor)'draftingNoteBuilder1.Origin.Origin.SetValue(Nothing, nullNXOpen_View, label_ABS_Loc) 
	draftingNoteBuilder1.Origin.SetInferRelativeToGeometry(True)
	leaderData1.StubSide= NXOpen.Annotations.LeaderSide.Right 
	Dim nXObject1 As NXOpen.NXObject=Nothing 
	nXObject1 = draftingNoteBuilder1.Commit()
	draftingNoteBuilder1.Destroy() 
	theSession.DeleteUndoMark(markId1, "Auto Label Points") 
Next 
ptsPoints.Clear()
ptsNames.Clear() 
Loop 
'********************'Clear Selection List'******************** 
'Dim markIdPartClean As NXOpen.Session.UndoMarkId = Nothing'markIdPartClean = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Part Cleanup") 
Dim partCleanup As NXOpen.PartCleanup=Nothing
partCleanup = theSession.NewPartCleanup()
partCleanup.TurnOffHighlighting=True
partCleanup.DoCleanup()
partCleanup.Dispose()'theSession.DeleteUndoMark(markIdPartClean, Nothing) 
EndSub 
Function SelDraftingView(ByVal prompt AsString, ByRef selView As Drawings.DraftingView)As Selection.Response 
	Dim theUI As UI = UI.GetUIDim title AsString="Select a drafting view"Dim includeFeatures AsBoolean=FalseDim keepHighlighted AsBoolean=FalseDim selAction As Selection.SelectionAction= Selection.SelectionAction.ClearAndEnableSpecificDim cursor As Point3d
        Dim scope As Selection.SelectionScope= Selection.SelectionScope.WorkPartDim selectionMask_array(0)As Selection.MaskTripleDim selObj As TaggedObject
 
        With selectionMask_array(0).Type= UFConstants.UF_view_type.Subtype= UFConstants.UF_all_subtypeEndWith 
        Dim resp As Selection.Response= theUI.SelectionManager.SelectTaggedObject(prompt, _
         title, scope, selAction, _
         includeFeatures, keepHighlighted, selectionMask_array, _
         selObj, cursor)If resp = Selection.Response.ObjectSelectedOrElse resp = Selection.Response.ObjectSelectedByNameThen
            selView =CType(selObj, Drawings.DraftingView)Return Selection.Response.OkElseReturn Selection.Response.CancelEndIf 
EndFunction 
PublicFunction SelectScreenPos(ByRef pos As Point3d)As Selection.DialogResponseDim theUI As UI = UI.GetUI()Dim view As NXOpen.View=NothingDim letteringPrefs As LetteringPreferences =NothingDim userSymPrefs As UserSymbolPreferences =NothingReturn theUI.SelectionManager.SelectScreenPosition("Select location for tabnote", view, pos)EndFunction 
PublicFunction GetUnloadOption(ByVal dummy AsString)AsInteger 
        '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 
EndFunction 
EndModule

Select face and add sketch

$
0
0

Hi together,

i created a UI Block Designer where i can select a face the ID will be face_select0.

I try to find the face with:

< NXOpen.Face face1 = (NXOpen.Face)workPart.FindObject("face_select0"); >

But this does not work. I get the error " No obect with this name found in NXOpen.NXObject.FindObject(String journalIdentifier)

Where is my problem?

Afterwards i want to add a sketch on this selected face. Maybe anybody can tell me what should be the first step!

Best regards!

MBD Application

$
0
0

Hello,

can you please share the documentation/Help link for MBD applications using Journaling and also some sample codes

Thanks in advance

Hole size & coordinate.

$
0
0

Hi all,

Greetings..

I want to create a NX custom command, which will help me to create an excel file. This Excel file is a standard format in my machine shop for hole coordinates and sizes according to WCS.

Currently I use "POINT INFORMATION" and copy the coordinate to that excel format individually one by one. I usually collect information about more than 50 holes coordinates and sizes.Then I add Top View, Front view and Isometric view in that format at designated location.

Can anyone suggest what should be done to get this result on that excel format? So that When I select multiple holes and previously saved views it should automatically create a new excel template with hole details and views of the part model.

Thanks & Regards,
Partha

Creating 2 Components with the Same Name

$
0
0

Hi,

I want to create 2 components as a children of another component. When manually copy-paste one component under the same parent, new component is created successfully. But when trying to create a component with journal, i can't create component with the same name. It gives me an error that i can't do that.

For Example:

Below hierarchy is valid when copy 'pXXX0101' and paste to same place. I can create many of them without problem with manually. But, when trying to create with NX Journal, it doesn't permit that. aXXX010000 is parent of pXXX010100 components.

-- aXXX010000
  -- pXXX010100
  -- pXXX010100

Actually, i know that even component names looks same in hierarchy, they hidden their real names. So, their names relatively:

-- aXXX010000
  -- pXXX010100 (1)
  -- pXXX010100 (2)

So my question is that how can i create a component with full name such as 'pXXX010100 (1)' ?

Thanks in advance.
Best regards.

trim / sort object names

$
0
0

Hello everyone,
I have below questions:

1> I have a list of points named as A1,B1,C1,D1... for some instances i want to remove the numbers from the end of the name...

2> also i have a point list with names such as A1 to A3, B1 to B3, C1 to C3 and so on... while sorting the list i get the result as A1,A2,A3,B1,B2,B3... but i want my result to be A1,B1,C1 / A2,B2,C2 / A3,B3,C3...

could someone help me with the above issues...

Thanks


Issue with Point Labeling

$
0
0

I have created labels for visible drafting points in a view by getting the 3D point object names. After a while i update the point names in 3D and when i recreate the labels for the same views, i am not getting the updated names from 3D. I tried creating a new view and labeled the points using the macro.(This way i am getting the updated names)

1>Is this a inherent nature of the drafting views..?? or
2>Is this something wrong with my journal...

i have posted the journal in the below link
http://www.nxjournaling.com/content/auto-label-creation-drafting-points

create Arrangement

$
0
0

Hello NX Journaling,
Is there any code available for creating arrangements..??
I have a recorded journal which adds few components and one assembly to the drawing. Creates arrangements as the same name as that of the parts and keeps the parent assembly as active arrangement and suppress other arrangements. I want to automate this with the inputs from excel file. Are there any example of journals which access the excel and updates the model ..??
Thanks, B

Bend Report YBC

$
0
0

I would like to get the bend report YCB information. Does sombody know how this command Works? Is it posible to work with every value in a separate way?

I have found some things about this command but I can't understand at all.

https://docs.plm.automation.siemens.com/data_services/resources/nx/12/nx...

https://docs.plm.automation.siemens.com/data_services/resources/nx/12/nx...

https://docs.plm.automation.siemens.com/data_services/resources/nx/12/nx...

I hope somebody can help me, thanks.

Retrieve component based on point3d

$
0
0

I am looking for a way to get all the component objects that have solid material in a certain point3d. Is this possible?

Below is a script that collects the positions of the selected parts. The idea is to create a new point on an offset of the found position and check if there is a component on that spot and get thats component name.

Option Strict Off
Imports System
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpenUI
Imports NXOpen.UF
 
 
Module Module1
 
    Sub Main()
 
        Dim theSession As Session = Session.GetSession()
        Dim theUI As UI = UI.GetUI
		Dim lw As ListingWindow = theSession.ListingWindow
 
        If IsNothing(theSession.Parts.BaseWork) Then
            'active part required
            Return
        End If
 
        Dim numsel As Integer = theUI.SelectionManager.GetNumSelectedObjects()
        Dim theComps As New List(Of Assemblies.Component)
 lw.Open()
        For i As Integer = 0 To numsel - 1
            Dim selObj As TaggedObject = theUI.SelectionManager.GetSelectedTaggedObject(i)
            If TypeOf (selObj) Is Assemblies.Component Then
                theComps.Add(selObj)
 
Dim pt As NXOpen.Point3d
 		Dim mx As NXOpen.Matrix3x3
 		theComps.Item(i).GetPosition(pt, mx)
		Dim axisZ As New NXOpen.Vector3d(mx.Zx, mx.Zy, mx.Zz)
 		lw.WriteLine(theComps.Item(i).Name)
 		lw.WriteLine( "; Position = " & pt.ToString)
 		lw.WriteLine( "; AxisZ = " & axisZ.ToString & vbCr)
 
 
            End If
        Next
 
 
        If theComps.Count = 0 Then
            'no components found among the preselected objects
			lw.WriteLine("no components found among the preselected objects")
 
            Return
        End If
 
        My.Computer.Clipboard.SetText(theComps.Item(0).Name)
 
		lw.WriteLine("Selected Objects: " & theComps.Item(0).Name)
 
 
    End Sub
 
 
    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

Incorrect Object for this Operation - SketchPolygonBuilder

$
0
0

Hi!

I try to add a Polygonface to any surface at a userselected point. Now i got the error "Incorrect Object for this Operation - NXOpen.Builder.Commit() "

Maybe the following code will help to understand the Problem:

     NXOpen.SketchPolygon nullNXOpen_SketchPolygon = null;
     NXOpen.SketchPolygonBuilder sketchPolygonBuilder1;
     sketchPolygonBuilder1 = workPart.Sketches.CreateSketchPolygonBuilder(nullNXOpen_SketchPolygon);
 
    //here is some Polygon code (dimensions/placing ect.)
 
    NXOpen.NXObject nXObject2;
    nXObject2 = sketchPolygonBuilder1.Commit();
 
    theSession.ActiveSketch.Update();
 
 

Point Co-ordinates Tabular note

$
0
0

Hi, below is the modified version of the Journal "point co-ordinates tabular note" by Cowski from eng-tips. (unable to trace the exact link to the original code.)
I have made below changes to the code:
1> Journal will select only the points which are visible in the view, irrespective of the any number of points in the view.
2> Rather than assigning points ID's, the point names(from 3D point object name) are associated to the co-ordinate values. (Before running this journal, 3D Point objects have to be assigned a name. Else the Point names would be blank).
3> Made a custom sort to the point names so that the points looks grouped.
(Sort works fine when the number at the end of the point name do not exceed 09. Used a crude approach for a custom sort of Point "Name" by reversing the string , sort the reversed string and then reverse the string again)

The source code was a very much useful reference and helped a lot for a beginner like me with some experimenting.

Now, i'am stuck with this code where i want to make small improvements.
How can i adjust the column width. I have 5 columns: and I want Column 1, Column 2 of different width and columns 3 to 5 of same width.

Also, the points are not associative, which i'am trying to make associative. Not sure if I would come back with a solution or a query to make the co-ordinates associative. :):)

' NX 12.0.1.7' Journal created by Balaji_Sampath03 on Mon Jul 13 20:50:40 2020 India Standard Time 
'**************************************************************************************'This Macro creates the co-ordinate point table for all visible drafting points in the view'Corresponding Point Names are also inserted in the table'Points are custom sorted before tabulating the co-ordinates'Points are tabulated in Global Co-ordinate system'***************************************************************************************Option Strict Off
 
Imports System
Imports System.Collections.GenericImports NXOpen
Imports NXOpen.AnnotationsImports NXOpen.UIImports NXOpen.UFImports NXOpen.UtilitiesImports System.Linq 
Module Tab_Coordinates
 
	Dim theSession As Session = Session.GetSession()Dim theUfSession As UFSession = UFSession.GetUFSession()Dim workPart As Part = theSession.Parts.WorkDim theUI As UI = UI.GetUI()'Dim displayPart As Part = theSession.Parts.DisplayDim theDraftView As Drawings.DraftingViewDim ptsPoints AsNew List(Of Point)Dim ptsNames AsNew List(OfString)Dim revNames AsNew List(OfString)Dim viewName AsString=NothingDim ptsCount AsInteger="0"Dim tempName AsString=NothingDim lw As ListingWindow = theSession.ListingWindow 
Sub Main (ByVal args()AsString) 
	lw.Open()Dim markId1 As NXOpen.Session.UndoMarkId=Nothing
	markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Co-Ordinates Table") 
Do Until SelDraftingView("select drafting view", theDraftView)= Selection.Response.Cancel 
	viewName = theDraftView.Name 
'Check for the points and points to list: Exit if there is no point'------------------------------------------------------------------ForEach tempObj As DisplayableObject In theDraftView.AskVisibleObjectsIfTypeOf tempObj Is Point Then
			ptsPoints.Add(tempObj)
			tempObj.HighlightEndIfNext 
            If ptsPoints.ToArray().Length=0Then
                lw.Open()
                lw.WriteLine("No Points found. Exit.")ReturnEndIf 
            'Get location for Co-ordinates Table'-----------------------------------Dim cursor As Point3d
            Dim response As Selection.DialogResponse= SelectScreenPos(cursor)If response <> Selection.DialogResponse.PickThenReturnEndIf 
'Reverse String before Sort'--------------------------ForEach tempObj As Point In ptsPoints
                'If custom sort is not needed comment out the below two lines and un-comment the last line of the loop'and comment the StrReverse code in Line 154 and un-comment the line 155Dim revName AsString=StrReverse(tempObj.Name)
                ptsNames.Add(revName)'ptsNames.Add(tempObj.Name)Next 
' Sort All point Names'------------------------
	ptsNames.Sort(AddressOf ComparePointNames) 
' Create the tabular note'------------------------Dim n_new_columns AsInteger=5Dim n_new_rows AsInteger=0Dim tabnote As NXOpen.Tag= CreateTabnoteWithSize(n_new_rows, n_new_columns, cursor) 
' Get the column tags'--------------------Dim columns(n_new_columns -1)As NXOpen.TagFor ii AsInteger=0To n_new_columns -1
			theUfSession.Tabnot.AskNthColumn(tabnote, ii, columns(ii))NextDim cell As NXOpen.Tag 
' Add Title Row'--------------Dim TitleRow As Tag
	Dim height AsDouble=NothingDim cellprefes As UFTabnot.CellPrefs=NothingDim cell1 As NXOpen.TagDim cell2 As NXOpen.TagDim cell3 As NXOpen.TagDim cell4 As NXOpen.Tag 
        theUfSession.Tabnot.CreateRow(30, TitleRow)
        theUfSession.Tabnot.AddRow(tabnote, TitleRow, UFConstants.UF_TABNOT_APPEND)
        theUfSession.Tabnot.AskCellAtRowCol(TitleRow, columns(2), cell1)
        theUfSession.Tabnot.AskCellAtRowCol(TitleRow, columns(4), cell2)
        theUfSession.Tabnot.AskCellAtRowCol(TitleRow, columns(0), cell3)
        theUfSession.Tabnot.AskCellAtRowCol(TitleRow, columns(1), cell4)
        theUfSession.Tabnot.MergeCells(cell1, cell2)
        theUfSession.Tabnot.AskCellAtRowCol(TitleRow, columns(0), cell)
        theUfSession.Tabnot.SetCellText(cell1, "Koordinaten von Ebenen RX,RY,RZ Coordinates from Planes RX, RY, RZ") 
' Add Header Row'---------------Dim headerrow As NXOpen.TagDim cell5 As NXOpen.TagDim cell6 As NXOpen.Tag 
        theUfSession.Tabnot.CreateRow(30, headerrow)
        theUfSession.Tabnot.AddRow(tabnote, headerrow, UFConstants.UF_TABNOT_APPEND)
        theUfSession.Tabnot.AskCellAtRowCol(headerrow, columns(0), cell)
        theUfSession.Tabnot.SetCellText(cell, "Kontrollmass Check Dimension")
	theUfSession.Tabnot.AskCellAtRowCol(headerrow, columns(1), cell)
        theUfSession.Tabnot.SetCellText(cell, "Schnitt Section")
        theUfSession.Tabnot.AskCellAtRowCol(headerrow, columns(2), cell)
        theUfSession.Tabnot.SetCellText(cell, "X")
        theUfSession.Tabnot.AskCellAtRowCol(headerrow, columns(3), cell)
        theUfSession.Tabnot.SetCellText(cell, "Y")
        theUfSession.Tabnot.AskCellAtRowCol(headerrow, columns(4), cell)
        theUfSession.Tabnot.SetCellText(cell, "Z") 
        theUfSession.Tabnot.AskCellAtRowCol(headerrow, columns(0), cell5)
        theUfSession.Tabnot.AskCellAtRowCol(headerrow, columns(1), cell6)
	theUfSession.Tabnot.MergeCells(cell3, cell5)
	theUfSession.Tabnot.MergeCells(cell4, cell6) 
' Add a row for each point'-------------------------Dim letteringPrefs As LetteringPreferences =NothingDim userSymPrefs As UserSymbolPreferences =Nothing 
	For i AsInteger=0to ptsPoints.Count-1
	ptsCount +=1 
                Dim row As NXOpen.Tag
               	theUfSession.Tabnot.CreateRow(30, row)
                theUfSession.Tabnot.AddRow(tabnote, row, UFConstants.UF_TABNOT_APPEND)
                theUfSession.Tabnot.AskCellAtRowCol(row, columns(0), cell)
                theUfSession.Tabnot.SetCellText(cell, StrReverse(ptsNames.Item(i)))'theUfSession.Tabnot.SetCellText(cell, ptsNames.Item(i)) 
                ' Set the cell text'------------------Dim ordVal(2)AsString 
		ordVal(0)= ptsPoints(i).Coordinates.X.ToString("F3")
        	ordVal(1)= ptsPoints(i).Coordinates.Y.ToString("F3")
        	ordVal(2)= ptsPoints(i).Coordinates.Z.ToString("F3") 
                theUfSession.Tabnot.AskCellAtRowCol(row, columns(2), cell)
	        theUfSession.Tabnot.SetCellText(cell, ordVal(0))
		theUfSession.Tabnot.AskCellAtRowCol(row, columns(3), cell)
                theUfSession.Tabnot.SetCellText(cell, ordVal(1))
                theUfSession.Tabnot.AskCellAtRowCol(row, columns(4), cell)
                theUfSession.Tabnot.SetCellText(cell, ordVal(2))Next 
' Clear Points & Name List'-------------------------
	ptsPoints.Clear()
	ptsNames.Clear() 
'Clear Selection List'-------------------- 
Dim partCleanup As NXOpen.PartCleanup=Nothing
partCleanup = theSession.NewPartCleanup()
partCleanup.TurnOffHighlighting=True
partCleanup.DoCleanup()
partCleanup.Dispose() 
Loop 
EndSub 
Function SelDraftingView(ByVal prompt AsString, ByRef selView As Drawings.DraftingView)As Selection.Response 
	Dim theUI As UI = UI.GetUIDim title AsString="Select a drafting view"Dim includeFeatures AsBoolean=FalseDim keepHighlighted AsBoolean=FalseDim selAction As Selection.SelectionAction= Selection.SelectionAction.ClearAndEnableSpecificDim cursor As Point3d
        Dim scope As Selection.SelectionScope= Selection.SelectionScope.WorkPartDim selectionMask_array(0)As Selection.MaskTripleDim selObj As TaggedObject
 
        With selectionMask_array(0).Type= UFConstants.UF_view_type.Subtype= UFConstants.UF_all_subtypeEndWith 
        Dim resp As Selection.Response= theUI.SelectionManager.SelectTaggedObject(prompt, _
         title, scope, selAction, _
         includeFeatures, keepHighlighted, selectionMask_array, _
         selObj, cursor)If resp = Selection.Response.ObjectSelectedOrElse resp = Selection.Response.ObjectSelectedByNameThen
            selView =CType(selObj, Drawings.DraftingView)Return Selection.Response.OkElseReturn Selection.Response.CancelEndIf 
EndFunction 
PublicFunction SelectScreenPos(ByRef pos As Point3d)As Selection.DialogResponseDim theUI As UI = UI.GetUI()Dim view As NXOpen.View=NothingDim letteringPrefs As LetteringPreferences =NothingDim userSymPrefs As UserSymbolPreferences =NothingReturn theUI.SelectionManager.SelectScreenPosition("Select location for tabnote", view, pos)EndFunction 
PublicFunction CreateTabnoteWithSize(ByVal nRows AsInteger,
                                          ByVal nColumns AsInteger,
                                          ByVal loc As Point3d)As NXOpen.Tag 
        Try' Create the tabular noteDim secPrefs As UFTabnot.SectionPrefs
        	theUfSession.Tabnot.AskDefaultSectionPrefs(secPrefs)Dim cellPrefs As UFTabnot.CellPrefs
        	theUfSession.Tabnot.AskDefaultCellPrefs(cellPrefs)
	        cellPrefs.zero_display= UFTabnot.ZeroDisplay.ZeroDisplayZero
        	cellPrefs.line_space_factor=1.0
	        cellPrefs.nm_fit_methods=3'cellPrefs.fit_methods(0) = UFTabnot.FitMethod.FitMethodAutoSizeRow'cellPrefs.fit_methods(1) = UFTabnot.FitMethod.FitMethodAutoSizeCol
		cellPrefs.fit_methods(2)= UFTabnot.FitMethod.FitMethodWrap		
		theUfSession.Tabnot.SetDefaultCellPrefs(cellPrefs) 
            Dim origin(2)AsDouble
            origin(0)= loc.X
            origin(1)= loc.Y
            origin(2)= loc.ZDim tabnote As NXOpen.Tag
            theUfSession.Tabnot.Create(secPrefs, origin, tabnote) 
            ' Delete all existing columns and rows (we create them as needed)Dim nmRows AsInteger=0
            theUfSession.Tabnot.AskNmRows(tabnote, nmRows)For ii AsInteger=0To nmRows -1Dim row As NXOpen.Tag
                theUfSession.Tabnot.AskNthRow(tabnote, 0, row)
                theUfSession.Tabnot.RemoveRow(row)
                theUfSession.Obj.DeleteObject(row)Next 
		Dim nmColumns AsInteger=0
            	theUfSession.Tabnot.AskNmColumns(tabnote, nmColumns)For ii AsInteger=0To nmColumns -1Dim column As NXOpen.Tag
                theUfSession.Tabnot.AskNthColumn(tabnote, 0, column)
                theUfSession.Tabnot.RemoveColumn(column)
                theUfSession.Obj.DeleteObject(column)Next 
            ' Now add our columns as neededDim columns(nColumns -1)As NXOpen.TagFor ii AsInteger=0To nColumns -1
                		theUfSession.Tabnot.CreateColumn(30, columns(ii))
                		theUfSession.Tabnot.AddColumn(tabnote, columns(ii), UFConstants.UF_TABNOT_APPEND)'ufs.Tabnot.AskColumnWidth(columns(i), width)'width = 0.75
            			theUfSession.Tabnot.SetColumnWidth(columns(ii), 50)Next 
            ' Now add our rows as neededDim rows(nRows -1)As NXOpen.TagFor ii AsInteger=0To nRows -1
                		theUfSession.Tabnot.CreateRow(30, rows(ii))
                		theUfSession.Tabnot.AddRow(tabnote, rows(ii), UFConstants.UF_TABNOT_APPEND) 
            		NextReturn tabnote		
 
        Catch ex As NXOpen.NXException
            lw.Open()
            lw.WriteLine(ex.Message) 
        Catch ex As Exception
            lw.Open()
            lw.WriteLine(ex.GetBaseException.ToString()) 
        EndTry 
EndFunction 
PrivateFunction ComparePointNames(ByVal x AsString, ByVal y AsString)AsInteger 
        'case-insensitive sortDim myStringComp As StringComparer = StringComparer.CurrentCultureIgnoreCase 
        'for a case-sensitive sort (A-Z then a-z), change the above option to:'Dim myStringComp As StringComparer = StringComparer.CurrentCulture 
        Return myStringComp.Compare(x, y) 
EndFunction 
PublicFunction GetUnloadOption(ByVal dummy AsString)AsInteger 
        '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 
EndFunction 
EndModule

NURBS surface generation

$
0
0

Is there an API function for NURBS surface generation?

On page 59 of Getting Started with NX Open, there is a function described for creation of a NURBS curve, specifying poles, weights, and knots. However, I haven't found a description for an equivalent function for NURBS surfaces.

That is, a function to which I can input poles, weights, and knots in the u and v directions and have a surface created.


Add Reference Dimensions to Faces on Bounding Box

$
0
0

Hello, I am trying to add PMI reference dimensions to the maximum dimensions of models in a dynamic way which works for as many geometry types as possible.

I have got it mostly working by using the bounding box to find points in the corner of models. As shown by the green highlight, I've asscociated the dimension with the points and the body.

https://drive.google.com/file/d/1KzEGZ74eh0yCXPhMXOmpvvSD58BLCZno/view?u...

However, I need to find a way of attaching the dimension to faces along the bounding box rather than arbitrary points. It should look like the image below.

https://drive.google.com/file/d/1Pnz3dP29lNvW3fNZFHUvNcxhY_5vZE6_/view?u...

Is it possible to find faces on the bounding box which could be added to the associativity in a dimension builder using a journal?

Journal for Engraving

$
0
0

Hello All,
Below journal creates the Engraving on the part body by extracting details from part attributes such as Description, Part number (removed the last 5 characters of the string from the part number for my requirement)& Weight.

' NX 12.0.1.7' Journal created by Balaji_Sampath03 on Tue Jul 21 20:07:10 2020 India Standard Time'**************************************************************************************'This Journal creates the Engraving on the NX part with attribute info such as'1> Description'2> Part Number (last 4 characters of the string from part number is removed) and '3> Weight'This Journal does not have any exception to catch any errors'Has option to invert the direction of the Offset curve before the final extrude option'***************************************************************************************Option Strict Off
Imports System
Imports System.Collections.GenericImports NXOpen
Imports NXOpen.UIImports NXOpen.UF 
Module NXJournal
 
	Dim theUfSession As UFSession = UFSession.GetUFSession()Dim theSession As NXOpen.Session= NXOpen.Session.GetSession()Dim workPart As NXOpen.Part= theSession.Parts.WorkDim displayPart As NXOpen.Part= theSession.Parts.DisplayDim lw As ListingWindow = theSession.ListingWindowDim theUI As UI = UI.GetUI() 
Sub Main (ByVal args()AsString) 
	Dim attDesc AsString=NothingDim attPartNum AsString=NothingDim attWeight AsDouble=NothingDim attributeInfo As NXObject.AttributeInformation 
' -------------------' GET USER ATTRIBUTES' ------------------- 
	If workPart.HasUserAttribute("DESCRIPTION", NXObject.AttributeType.Any, -1)Then
		attributeInfo = workPart.GetUserAttribute("Description", NXObject.AttributeType.String, -1)
    		attDesc = attributeInfo.StringValueElse
		lw.WriteLine("Attribute 'DESCRIPTION' is not present")EndIf 
	If workPart.HasUserAttribute("Weight", NXObject.AttributeType.Any, -1)ThenDim aInfo As NXObject.AttributeInformation
		aInfo = workPart.GetUserAttribute("Weight", NXObject.AttributeType.Any, -1)
    		attWeight = aInfo.StringValueElse
		lw.WriteLine("Attribute 'Weight' is not present")
		attWeight =" "EndIf 
	attPartnum = workPart.Name 
' -----------------------------------------------------------------' CREATE FEATURE GROUP "ENGRAVE TEXT" AND MAKE FEATURE GROUP ACTIVE' ----------------------------------------------------------------- 
Dim markId1 As NXOpen.Session.UndoMarkId=Nothing
markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Feature Groups") 
Dim activatefeaturegroupwithrollback1 AsBoolean=Nothing
activatefeaturegroupwithrollback1 = theSession.Preferences.Modeling.ActivateFeatureGroupWithRollback 
Dim featuresToGroup As Tag()=NothingDim theFeatureGroupTag As Tag =Nothing
theUfSession.Modl.CreateSetOfFeature("ENGRAVE TEXT", featuresToGroup, 0, 1, theFeatureGroupTag) 
	ForEach myFeature As Features.FeatureIn workPart.FeaturesIfTypeOf(myFeature)Is NXOpen.Features.FeatureGroupThenIf myFeature.FeatureType="FSET"And myFeature.Name="ENGRAVE TEXT"Then
                    		myFeature.MakeCurrentFeature()
				myFeature.SetGroupActive(True)EndIfEndIfNext 
' ---------------------------------------------------' SET PARAMETERS FOR CURVE SEL AND FACE OFFSET METHOD' --------------------------------------------------- 
Dim nullNXOpen_Features_Feature As NXOpen.Features.Feature=Nothing 
Dim aOCSBuilder1 As NXOpen.Features.AOCSBuilder=Nothing
aOCSBuilder1 = workPart.Features.CreateAocsBuilder(nullNXOpen_Features_Feature) 
Dim lawBuilder1 As NXOpen.GeometricUtilities.LawBuilder=Nothing
lawBuilder1 = aOCSBuilder1.Law 
Dim alongSpineBuilder1 As NXOpen.GeometricUtilities.AlongSpineBuilder=Nothing
alongSpineBuilder1 = lawBuilder1.AlongSpineData 
Dim unit1 As NXOpen.Unit=Nothing
unit1 = aOCSBuilder1.FilletRadius.Units 
Dim curveFitData1 As NXOpen.GeometricUtilities.CurveFitData=Nothing
curveFitData1 = aOCSBuilder1.CurveFitData 
Dim nullNXOpen_ScCollector As NXOpen.ScCollector=Nothing 
aOCSBuilder1.FaceCollector= nullNXOpen_ScCollector
 
aOCSBuilder1.OffsetDistType= NXOpen.Features.AOCSBuilder.OffsetDistanceType.Constant
aOCSBuilder1.OffsetDirectionOption= NXOpen.Features.AOCSBuilder.OffsetDirection.NormalToCurve
aOCSBuilder1.OffsetMode= NXOpen.Features.AOCSBuilder.OffsetType.Tangential
aOCSBuilder1.TrimMethod= NXOpen.Features.AOCSBuilder.Trim.WithinSection
aOCSBuilder1.ExtendMethod= NXOpen.Features.AOCSBuilder.Extend.WithinSection
aOCSBuilder1.TrimToFaceEdgesOption=False
aOCSBuilder1.ExtendToFaceOption= NXOpen.Features.AOCSBuilder.ExtendToFace.Boundary
aOCSBuilder1.RemoveSelfIntersections=True
aOCSBuilder1.AssociativeOutputOption=True
aOCSBuilder1.LawStringFlip=False
aOCSBuilder1.SplitCurveOption=True
aOCSBuilder1.OffsetDirectionOption= NXOpen.Features.AOCSBuilder.OffsetDirection.NormalToCurve 
aOCSBuilder1.FilletOption= NXOpen.Features.AOCSBuilder.FilletOptions.NoFillet
aOCSBuilder1.CurveOffsetType= NXOpen.Features.AOCSBuilder.CurveOffsetTypes.Value 
Dim nullNXOpen_Point As NXOpen.Point=Nothing 
aOCSBuilder1.ThroughPoint= nullNXOpen_Point
 
Dim objectList1 As NXOpen.ObjectList=Nothing
objectList1 = alongSpineBuilder1.SpinePointList
objectList1.Clear(NXOpen.ObjectList.DeleteOption.Delete) 
Dim origin1 As NXOpen.Point3d=New NXOpen.Point3d(0.0, 0.0, 0.0)Dim vector1 As NXOpen.Vector3d=New NXOpen.Vector3d(1.0, 0.0, 0.0)Dim direction1 As NXOpen.Direction=Nothing
direction1 = workPart.Directions.CreateDirection(origin1, vector1, NXOpen.SmartObject.UpdateOption.WithinModeling) 
aOCSBuilder1.ProjectPlaneNormal= direction1
 
Dim section1 As NXOpen.Section=Nothing
section1 = workPart.Sections.CreateSection(0.0094999999999999998, 0.01, 0.5) 
Dim nullNXOpen_Section As NXOpen.Section=Nothing 
Dim expressionSectionSet1 As NXOpen.ExpressionSectionSet=Nothing
expressionSectionSet1 = workPart.CreateExpressionSectionSet(nullNXOpen_Section, "2", "Length", 0) 
expressionSectionSet1.ItemFlipFlag=True
aOCSBuilder1.Offsets.Append(expressionSectionSet1) 
section1.SetAllowedEntityTypes(NXOpen.Section.AllowTypes.OnlyCurves) 
' ------------------------'   SELECT CURVE TO OFFSET' ------------------------ 
	Dim pickEdge As Edge
 
	If SelectEdge("Select Edge", pickEdge)= Selection.Response.CancelThenReturnEndIf 
Dim edges1(0)As NXOpen.Edge
edges1(0)= pickEdge
 
Dim edgeDumbRule1 As NXOpen.EdgeDumbRule=Nothing
edgeDumbRule1 = workPart.ScRuleFactory.CreateRuleEdgeDumb(edges1) 
section1.AllowSelfIntersection(False) 
Dim rules1(0)As NXOpen.SelectionIntentRule
rules1(0)= edgeDumbRule1
Dim nullNXOpen_NXObject As NXOpen.NXObject=Nothing 
Dim helpPoint1 As NXOpen.Point3d=New NXOpen.Point3d(-51.890018880214939, -40.000000000000043, 10.0)
section1.AddToSection(rules1, pickEdge, nullNXOpen_NXObject, nullNXOpen_NXObject, helpPoint1, NXOpen.Section.Mode.Create, False) 
expressionSectionSet1.Section= section1
 
' ----------------------' SELECT FACE FOR OFFSET' ---------------------- 
Dim scCollector1 As NXOpen.ScCollector=Nothing
scCollector1 = workPart.ScCollectors.CreateCollector() 
Dim pickFace As Face
SelectAFace("select a face", pickFace) 
	Dim faces1(0)As NXOpen.Face
	faces1(0)= pickFace
 
	Dim faceDumbRule1 As NXOpen.FaceDumbRule=Nothing
	faceDumbRule1 = workPart.ScRuleFactory.CreateRuleFaceDumb(faces1)Dim rules2(0)As NXOpen.SelectionIntentRule
	rules2(0)= faceDumbRule1
	scCollector1.ReplaceRules(rules2, False) 
	aOCSBuilder1.FaceCollector= scCollector1
	aOCSBuilder1.UpdateFaces() 
	Dim feature1 As NXOpen.Features.Feature=Nothing
	feature1 = aOCSBuilder1.CommitFeature()
	aOCSBuilder1.Destroy() 
' -------------------------------------------' INSERT TEXT 1 AND SEL OFFSET CURVE FOR TEXT' ------------------------------------------- 
Dim nullNXOpen_Features_Text As NXOpen.Features.Text=Nothing 
Dim textBuilder1 As NXOpen.Features.TextBuilder=Nothing
textBuilder1 = workPart.Features.CreateTextBuilder(nullNXOpen_Features_Text) 
textBuilder1.TextString=("WEIGHT: "& attWeight.ToString("0.00")&" kg")
textBuilder1.FrameOnPath.AnchorPosition.Expression.RightHandSide="50"
textBuilder1.Type= NXOpen.Features.TextBuilder.Types.OnFace
textBuilder1.PlanarFrame.Shear.RightHandSide="0"
textBuilder1.FrameOnPath.AnchorLocation= NXOpen.GeometricUtilities.FrameOnPathBuilder.AnchorLocationType.Left
textBuilder1.FrameOnPath.AnchorPosition.Expression.RightHandSide="5"
textBuilder1.FrameOnPath.Height.RightHandSide="5"
textBuilder1.PrintMarkThickness.RightHandSide="1"
textBuilder1.FrameOnPath.WScale=100.0
textBuilder1.FrameOnPath.Offset.RightHandSide="0"
textBuilder1.SelectFont("Arial", NXOpen.Features.TextBuilder.ScriptOptions.Western) 
Dim boundaryFaces1(-1)As NXOpen.FaceDim faceTangentRule1 As NXOpen.FaceTangentRule=Nothing
faceTangentRule1 = workPart.ScRuleFactory.CreateRuleFaceTangent(pickFace, boundaryFaces1, 0.5) 
Dim rules3(0)As NXOpen.SelectionIntentRule
rules3(0)= faceTangentRule1
textBuilder1.PlacementFaces.ReplaceRules(rules3, False) 
textBuilder1.OnFacePlacementProfile.SetAllowedEntityTypes(NXOpen.Section.AllowTypes.OnlyCurves) 
Dim features1(0)As NXOpen.Features.FeatureDim aOCS1 As NXOpen.Features.AOCS=CType(feature1, NXOpen.Features.AOCS) 
features1(0)= aOCS1
Dim line1 As NXOpen.Line=CType(aOCS1.FindObject("CURVE 1"), NXOpen.Line) 
Dim nullNXOpen_Curve As NXOpen.Curve=Nothing 
Dim curveFeatureTangentRule1 As NXOpen.CurveFeatureTangentRule=Nothing
curveFeatureTangentRule1 = workPart.ScRuleFactory.CreateRuleCurveFeatureTangent(features1, line1, nullNXOpen_Curve, False, 0.01, 0.5) 
textBuilder1.OnFacePlacementProfile.AllowSelfIntersection(True) 
Dim rules4(0)As NXOpen.SelectionIntentRule
rules4(0)= curveFeatureTangentRule1
Dim helpPoint2 As NXOpen.Point3d=New NXOpen.Point3d(-56.880335976917863, -6.0840221749458578e-14, 10.000000000000043)
textBuilder1.OnFacePlacementProfile.AddToSection(rules4, line1, nullNXOpen_NXObject, nullNXOpen_NXObject, helpPoint2, NXOpen.Section.Mode.Create, False) 
Dim nXObject1 As NXOpen.NXObject=Nothing
nXObject1 = textBuilder1.Commit() 
textBuilder1.Destroy() 
' -------------------------------------------' INSERT TEXT 2 AND SEL OFFSET CURVE FOR TEXT' ------------------------------------------- 
Dim textBuilder2 As NXOpen.Features.TextBuilder=Nothing
textBuilder2 = workPart.Features.CreateTextBuilder(nullNXOpen_Features_Text) 
Dim trimmedAttPartNum AsString= attPartnum.Remove( attPartnum.Length-5) 
textBuilder2.TextString= trimmedAttPartNum
textBuilder2.FrameOnPath.AnchorPosition.Expression.RightHandSide="50"
textBuilder2.Type= NXOpen.Features.TextBuilder.Types.OnFace
textBuilder2.PlanarFrame.Shear.RightHandSide="0"
textBuilder2.FrameOnPath.AnchorLocation= NXOpen.GeometricUtilities.FrameOnPathBuilder.AnchorLocationType.Left
textBuilder2.FrameOnPath.AnchorPosition.Expression.RightHandSide="5"
textBuilder2.FrameOnPath.Height.RightHandSide="5"
textBuilder2.PrintMarkThickness.RightHandSide="1"
textBuilder2.FrameOnPath.WScale=100.0
textBuilder2.FrameOnPath.Offset.RightHandSide="7"
textBuilder2.SelectFont("Arial", NXOpen.Features.TextBuilder.ScriptOptions.Western) 
Dim boundaryFaces2(-1)As NXOpen.FaceDim faceTangentRule2 As NXOpen.FaceTangentRule=Nothing
faceTangentRule1 = workPart.ScRuleFactory.CreateRuleFaceTangent(pickFace, boundaryFaces2, 0.5) 
Dim rules5(0)As NXOpen.SelectionIntentRule
rules5(0)= faceTangentRule1
textBuilder2.PlacementFaces.ReplaceRules(rules5, False) 
textBuilder2.OnFacePlacementProfile.SetAllowedEntityTypes(NXOpen.Section.AllowTypes.OnlyCurves) 
Dim features2(0)As NXOpen.Features.Feature
features2(0)= aOCS1
Dim line3 As NXOpen.Line=CType(aOCS1.FindObject("CURVE 1"), NXOpen.Line) 
Dim curveFeatureTangentRule2 As NXOpen.CurveFeatureTangentRule=Nothing
curveFeatureTangentRule2 = workPart.ScRuleFactory.CreateRuleCurveFeatureTangent(features2, line3, nullNXOpen_Curve, False, 0.01, 0.5) 
textBuilder2.OnFacePlacementProfile.AllowSelfIntersection(True) 
Dim rules6(0)As NXOpen.SelectionIntentRule
rules6(0)= curveFeatureTangentRule1
Dim helpPoint3 As NXOpen.Point3d=New NXOpen.Point3d(-56.880335976917863, -6.0840221749458578e-14, 10.000000000000043)
textBuilder2.OnFacePlacementProfile.AddToSection(rules6, line3, nullNXOpen_NXObject, nullNXOpen_NXObject, helpPoint3, NXOpen.Section.Mode.Create, False) 
Dim nXObject2 As NXOpen.NXObject=Nothing
nXObject2 = textBuilder2.Commit() 
textBuilder2.Destroy() 
' -------------------------------------------' INSERT TEXT 3 AND SEL OFFSET CURVE FOR TEXT' ------------------------------------------- 
Dim textBuilder3 As NXOpen.Features.TextBuilder=Nothing
textBuilder3 = workPart.Features.CreateTextBuilder(nullNXOpen_Features_Text) 
textBuilder3.TextString= attDesc
 
textBuilder3.FrameOnPath.AnchorPosition.Expression.RightHandSide="50"
textBuilder3.Type= NXOpen.Features.TextBuilder.Types.OnFace
textBuilder3.PlanarFrame.Shear.RightHandSide="0"
textBuilder3.FrameOnPath.AnchorLocation= NXOpen.GeometricUtilities.FrameOnPathBuilder.AnchorLocationType.Left
textBuilder3.FrameOnPath.AnchorPosition.Expression.RightHandSide="5"
textBuilder3.FrameOnPath.Height.RightHandSide="5"
textBuilder3.PrintMarkThickness.RightHandSide="1"
textBuilder3.FrameOnPath.WScale=100.0
textBuilder3.FrameOnPath.Offset.RightHandSide="14"
textBuilder3.SelectFont("Arial", NXOpen.Features.TextBuilder.ScriptOptions.Western) 
Dim boundaryFaces3(-1)As NXOpen.FaceDim faceTangentRule3 As NXOpen.FaceTangentRule=Nothing
faceTangentRule1 = workPart.ScRuleFactory.CreateRuleFaceTangent(pickFace, boundaryFaces3, 0.5) 
Dim rules7(0)As NXOpen.SelectionIntentRule
rules7(0)= faceTangentRule1
textBuilder3.PlacementFaces.ReplaceRules(rules7, False) 
textBuilder3.OnFacePlacementProfile.SetAllowedEntityTypes(NXOpen.Section.AllowTypes.OnlyCurves) 
Dim features3(0)As NXOpen.Features.Feature
features3(0)= aOCS1
Dim line4 As NXOpen.Line=CType(aOCS1.FindObject("CURVE 1"), NXOpen.Line) 
Dim curveFeatureTangentRule3 As NXOpen.CurveFeatureTangentRule=Nothing
curveFeatureTangentRule3 = workPart.ScRuleFactory.CreateRuleCurveFeatureTangent(features3, line4, nullNXOpen_Curve, False, 0.01, 0.5) 
textBuilder3.OnFacePlacementProfile.AllowSelfIntersection(True) 
Dim rules8(0)As NXOpen.SelectionIntentRule
rules8(0)= curveFeatureTangentRule3
Dim helpPoint4 As NXOpen.Point3d=New NXOpen.Point3d(-56.880335976917863, -6.0840221749458578e-14, 10.000000000000043)
textBuilder3.OnFacePlacementProfile.AddToSection(rules8, line4, nullNXOpen_NXObject, nullNXOpen_NXObject, helpPoint4, NXOpen.Section.Mode.Create, False) 
Dim nXObject3 As NXOpen.NXObject=Nothing
nXObject3 = textBuilder3.Commit() 
textBuilder3.Destroy() 
' ------------------------------' REVERSE OFFSET CURVE DIRECTION' ------------------------------Dim answer AsInteger= theUI.NXMessageBox.Show("Offset Curve Direction",
                     NXOpen.NXMessageBox.DialogType.Question, "Change Offset Curve Direction..?") 
	If answer =1Then 
		Dim editWithRollbackManager1 As NXOpen.Features.EditWithRollbackManager=Nothing
		editWithRollbackManager1 = workPart.Features.StartEditWithRollbackManager(aOCS1, markId1) 
		Dim aOCSBuilder2 As NXOpen.Features.AOCSBuilder=Nothing
		aOCSBuilder2 = workPart.Features.CreateAocsBuilder(aOCS1) 
		Dim taggedObject2 As NXOpen.TaggedObject=Nothing
		taggedObject2 = aOCSBuilder2.Offsets.FindItem(0) 
		Dim expressionSectionSet2 As NXOpen.ExpressionSectionSet=CType(taggedObject2, NXOpen.ExpressionSectionSet) 
		section1.ReverseDirectionOfLoop(0) 
		Dim flipDirection1 AsBoolean=Nothing
		flipDirection1 = aOCSBuilder2.UpdateSectionData(section1) 
		Dim feature2 As NXOpen.Features.Feature=Nothing
		feature2 = aOCSBuilder2.CommitFeature() 
		editWithRollbackManager1.UpdateFeature(False)
		editWithRollbackManager1.Stop()
		editWithRollbackManager1.Destroy()EndIf 
' ----------------------------------------------' SELECT TEXT TO EXTRUDE & BODY TO SUBTRACT FROM' ---------------------------------------------- 
Dim EdgeOBJ as Edge = pickEdge
Dim text2SubFrom As Body = EdgeOBJ.GetBody() 
Dim extrudeBuilder1 As NXOpen.Features.ExtrudeBuilder=Nothing
extrudeBuilder1 = workPart.Features.CreateExtrudeBuilder(nullNXOpen_Features_Feature) 
Dim section5 As NXOpen.Section=Nothing
section5 = workPart.Sections.CreateSection(0.0094999999999999998, 0.01, 0.5) 
extrudeBuilder1.Section= section5
 
Dim targetBodies1(0)As NXOpen.BodyDim nullNXOpen_Body As NXOpen.Body=Nothing
targetBodies1(0)= nullNXOpen_Body
 
extrudeBuilder1.BooleanOperation.SetTargetBodies(targetBodies1)
extrudeBuilder1.Limits.StartExtend.Value.RightHandSide="0.5"
extrudeBuilder1.Limits.EndExtend.Value.RightHandSide="-0.5"
extrudeBuilder1.BooleanOperation.Type= NXOpen.GeometricUtilities.BooleanOperation.BooleanType.Subtract 
Dim targetBodies2(0)As NXOpen.Body 
targetBodies2(0)= text2SubFrom
 
extrudeBuilder1.BooleanOperation.SetTargetBodies(targetBodies2) 
Dim smartVolumeProfileBuilder1 As NXOpen.GeometricUtilities.SmartVolumeProfileBuilder=Nothing
smartVolumeProfileBuilder1 = extrudeBuilder1.SmartVolumeProfile 
Dim features4(0)As NXOpen.Features.FeatureDim text1 As NXOpen.Features.Text=CType(nXObject1, NXOpen.Features.Text)
features4(0)= text1
Dim features5(0)As NXOpen.Features.FeatureDim text2 As NXOpen.Features.Text=CType(nXObject2, NXOpen.Features.Text)
features5(0)= text2
Dim features6(0)As NXOpen.Features.FeatureDim text3 As NXOpen.Features.Text=CType(nXObject3, NXOpen.Features.Text)
features6(0)= text3
 
Dim curveFeatureRule1 As NXOpen.CurveFeatureRule=Nothing
curveFeatureRule1 = workPart.ScRuleFactory.CreateRuleCurveFeature(features4)Dim curveFeatureRule2 As NXOpen.CurveFeatureRule=Nothing
curveFeatureRule2 = workPart.ScRuleFactory.CreateRuleCurveFeature(features5)Dim curveFeatureRule3 As NXOpen.CurveFeatureRule=Nothing
curveFeatureRule3 = workPart.ScRuleFactory.CreateRuleCurveFeature(features6) 
Dim rules9(0)As NXOpen.SelectionIntentRule
rules9(0)= curveFeatureRule1
Dim helpPoint5 As NXOpen.Point3d=New NXOpen.Point3d(0.0, 0.0, 0.0)
section5.AddToSection(rules9, nullNXOpen_NXObject, nullNXOpen_NXObject, nullNXOpen_NXObject, helpPoint5, NXOpen.Section.Mode.Create, False) 
Dim rules10(0)As NXOpen.SelectionIntentRule
rules10(0)= curveFeatureRule2
Dim helpPoint6 As NXOpen.Point3d=New NXOpen.Point3d(0.0, 0.0, 0.0)
section5.AddToSection(rules10, nullNXOpen_NXObject, nullNXOpen_NXObject, nullNXOpen_NXObject, helpPoint6, NXOpen.Section.Mode.Create, False) 
Dim rules11(0)As NXOpen.SelectionIntentRule
rules11(0)= curveFeatureRule3
Dim helpPoint7 As NXOpen.Point3d=New NXOpen.Point3d(0.0, 0.0, 0.0)
section5.AddToSection(rules11, nullNXOpen_NXObject, nullNXOpen_NXObject, nullNXOpen_NXObject, helpPoint7, NXOpen.Section.Mode.Create, False) 
Dim origin3 As NXOpen.Point3d=New NXOpen.Point3d(-46.124198330506573, 7.7841263299248453, 10.0)Dim vector2 As NXOpen.Vector3d=New NXOpen.Vector3d(0.0, 0.0, 1.0)Dim direction2 As NXOpen.Direction=Nothing
direction2 = workPart.Directions.CreateDirection(origin3, vector2, NXOpen.SmartObject.UpdateOption.WithinModeling) 
extrudeBuilder1.Direction= direction2
extrudeBuilder1.ParentFeatureInternal=False 
Dim feature3 As NXOpen.Features.Feature=Nothing
feature3 = extrudeBuilder1.CommitFeature() 
extrudeBuilder1.Destroy() 
'--------------------'Clear Selection List'-------------------- 
Dim partCleanup As NXOpen.PartCleanup=Nothing
partCleanup = theSession.NewPartCleanup()
partCleanup.TurnOffHighlighting=True
partCleanup.DoCleanup()
partCleanup.Dispose() 
EndSub 
Function SelectAFace(ByVal prompt AsString, ByRef selObj As Face)As Selection.Response 
        Dim theUI As UI = UI.GetUIDim title AsString="pickFace"Dim includeFeatures AsBoolean=FalseDim keepHighlighted AsBoolean=TrueDim selAction As Selection.SelectionAction= Selection.SelectionAction.ClearAndEnableSpecificDim cursor As Point3d
        Dim scope As Selection.SelectionScope= Selection.SelectionScope.AnyInAssemblyDim selectionMask_array(0)As Selection.MaskTriple 
        With selectionMask_array(0).Type= UFConstants.UF_solid_type.SolidBodySubtype= UFConstants.UF_UI_SEL_FEATURE_ANY_FACEEndWith 
        Dim resp As Selection.Response= theUI.SelectionManager.SelectObject(prompt, _
         title, scope, selAction, _
         includeFeatures, keepHighlighted, selectionMask_array, _
         selObj, cursor)If resp = Selection.Response.ObjectSelectedOrElse resp = Selection.Response.ObjectSelectedByNameThenReturn Selection.Response.OkElseReturn Selection.Response.CancelEndIf 
EndFunction 
Function SelectEdge(ByVal prompt AsString, ByRef selObj As TaggedObject)As Selection.Response 
        Dim theUI As UI = UI.GetUIDim title AsString="pickEdge"Dim includeFeatures AsBoolean=FalseDim keepHighlighted AsBoolean=TrueDim selAction As Selection.SelectionAction= Selection.SelectionAction.ClearAndEnableSpecificDim cursor As Point3d
        Dim scope As Selection.SelectionScope= Selection.SelectionScope.WorkPartDim selectionMask_array(0)As Selection.MaskTriple 
        With selectionMask_array(0).Type= UFConstants.UF_solid_type.SolidBodySubtype= UFConstants.UF_UI_SEL_FEATURE_ANY_EDGEEndWith 
        Dim resp As Selection.Response= theUI.SelectionManager.SelectTaggedObject(prompt, _
         title, scope, selAction, _
         includeFeatures, keepHighlighted, selectionMask_array, _
         selobj, cursor)If resp = Selection.Response.ObjectSelectedOrElse resp = Selection.Response.ObjectSelectedByNameThenReturn Selection.Response.OkElseReturn Selection.Response.CancelEndIf 
EndFunction 
PublicFunction GetUnloadOption(ByVal dummy AsString)AsInteger 
        'Unloads the image when the NX session terminates
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination 
        '----Other unload options-------'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'------------------------------- 
EndFunction 
EndModule

Selecting and Deleting Small Solid Bodies

$
0
0

I have a problem where an imported Printed Circuit Board includes thousands of small bodies that need to be deleted.

Does anyone have any ideas about how to do that?

Best Regards

Jon Schmidt

WinForms

$
0
0

Hello

I have created winforms as code available in this site
http://www.nxjournaling.com/content/using-winforms-journals

I have created winform for project, Drawn, checked, date etc for Title Block update
and in title block created note as * and assigned attribute like
<WRef1*0@PROJECT>
<WRef2*0@DRAWN>
<WRef3*0@CHECKED>
<WRef4*0@DATE>
etc

It is working fine for some attributes and for some I need to manually change like WRef7 to WRef3, then it will update, can you please help me to solve above issue

Thank you In advance

Creating a point on Spline/Curve

$
0
0

Hi There, I need some help in creating a topmost/closest point on the peak of profile of a spline/curve by creating a minimum distance with respect to a plane. When I run a Journal it is generating its own identifier as shown below which cannot be used with a different part.

spline1 = workPart.Splines.FindObject("ENTITY 9 12 1")
measureDistanceBuilder1.Object2.Value = spline1

It would be a great if someone can help in coding to replacing the identifier with different name, where I can run the journal for different parts too.

Currently I am using Python interface, Visual basic is also fine.

Thanks

Viewing all 783 articles
Browse latest View live