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:
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
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