Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Journal to set/ change dimensions tolerance

Status
Not open for further replies.

niedzviedz

Mechanical
Apr 1, 2012
307
Hello,

I want create journal to automatically set (or change already setted) dimensions tolerance. The macro must have:
1) possibility to select more than one dimension
2) possibility to reset previously setted value
3) possibility to select different kinds of dimension (radius, diameter, horizontal, vertical, parallel etc.)

I already wrote some of code, by the main problem is that, I don't know how fix selection of more than one dimension, and I can't set values.
Below is my code:
Code:
Option Strict Off

Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.UI
Imports NXOpen.Annotations

Module journal

    Sub Main

	Dim theSession As Session = Session.GetSession()
	Dim ufs As UFSession = UFSession.GetUFSession()
	Dim workPart As Part = theSession.Parts.Work
	Dim displayPart As Part = theSession.Parts.Display
	Dim lw As ListingWindow = theSession.ListingWindow
	Dim theAnnotationManager as NXOpen.Annotations.AnnotationManager = workPart.Annotations
	'Dim theAnnotationManager as AnnotationManager = workPart.Annotations

	Dim sel As Selection = NXOpen.UI.GetUI.SelectionManager
	Dim noteDim As Annotation
	Dim Dimension1 As Annotations.Dimension

	Dim response1 As Selection.Response = Selection.Response.Cancel

	response1 = select_Dim("Select a Curve", noteDim) 

	If response1 = Selection.Response.Cancel Then 
		Return
	End if
'----------------------------------------------
' this code is coped from recorded journal
'----------------------------------------------

	Dim linearTolerance1 As Annotations.LinearTolerance
	linearTolerance1.LimitFitDeviation = "g"
	linearTolerance1.LimitFitGrade = 6
	Dimension1.SetTolerance(linearTolerance1)
'------------------------------------------------- 
    End Sub

    Function Select_dim(ByVal prompt As String, ByRef obj As annotation)
      
        Dim message As String = "Select dimensions"
        Dim title As String = "Selection"
	Dim ui As UI = NXOpen.UI.GetUI
	Dim scope As Selection.SelectionScope = Selection.SelectionScope.WorkPart
'        Dim scope As Selection.SelectionScope = Selection.SelectionScope.AnyInAssembly
	Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific
        Dim selectionMask_array(0) As Selection.MaskTriple
	Dim includeFeatures As Boolean = False
        Dim keepHighlighted As Boolean = False

        With selectionMask_array(0)
            .Type = UFConstants.UF_dimension_type
            .Subtype = 0
            .SolidBodySubtype = 0
        End With

	Dim cursor As Point3d = Nothing

        Dim resp As Selection.Response = _
        ui.SelectionManager.SelectObject(prompt, message, _
            scope, _
            SelAction, _
            includeFeatures, keepHighlighted, selectionMask_array, obj, cursor)

	If resp = Selection.Response.Ok Then
            Return Selection.Response.Ok
        Else
            Return Selection.Response.Cancel
        End If
  
    End Function

    Public Function GetUnloadOption(ByVal dummy As String) As Integer

        GetUnloadOption = NXOpen.UF.UFConstants.UF_UNLOAD_IMMEDIATELY
     
    End Function
End Module

This journal must set dimension tolerance to "g6", but after selecting do nothing.
Could someone can help me improve this code?

with best regards
Michael

 
Replies continue below

Recommended for you

Thanks Frank, once again, for Your support. I tried many combination, but I didn't think that " " will solve it. Is there any "function" to restore changed value?

Below I attached 2 journals. First adds appended text "M" before dimension, second change specific dimension value to G (from 1/8" - G 1") (British standard pipe parallel). Maybe It will be useful to someone in the future.

with best regards
Michael
 
 http://files.engineering.com/getfile.aspx?folder=81bbba29-3300-4b4e-881a-3a10c938b134&file=Threads.7z
Where do I put the DimTolerances.dlx? Sorry for the question. I run Siemens NX for at least a few weeks.
 
You have to create system Environment variable:
name: UGII_USER_DIR
value x:\user_dir
And in this dir You have to create dir: application, where You put this file. Everything is written in the vb file. Bellow I quote this comment:
Code:
        '------------------------------- DIALOG LAUNCHING ---------------------------------
        '
        '    Before invoking this application one needs to open any part/empty part in NX
        '    because of the behavior of the blocks.
        '
        '    Make sure the dlx file is in one of the following locations:
        '        1.) From where NX session is launched
        '        2.) $UGII_USER_DIR/application
        '        3.) For released applications, using UGII_CUSTOM_DIRECTORY_FILE is highly
        '            recommended. This variable is set to a full directory path to a file 
        '            containing a list of root directories for all custom applications.
        '            e.g., UGII_CUSTOM_DIRECTORY_FILE=$UGII_ROOT_DIR\menus\custom_dirs.dat
        '
        '    You can create the dialog using one of the following way:
        '
        '    1. Journal Replay
        '
        '        1) Replay this file through Tool->Journal->Play Menu.
        '
        '    2. USER EXIT
        '
        '        1) Create the Shared Library -- Refer "Block UI Styler programmer's guide"
        '        2) Invoke the Shared Library through File->Execute->NX Open menu.
        '
        '------------------------------------------------------------------------------

with best regards
Michael

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor