nxexplorer
Mechanical
- Jun 23, 2010
- 84
Hi All,
I am interested with thread561-366113
From that great code by COWSKI, I try to make assumption for Cylinder Diameter from base rectangle,
that Diameter Value with Pythagoras Law :
Diameter = Sqrt((boundX) ^ 2 + (boundY) ^ 2)
I have set the attribute for triggering the something like BoundType, B or C (Block or Cylinder). Also for the purpose of Inventory, The Block Size always X size smaller then Y size, and Y size smaller than Z size. But the point in this thread is about Bounding BOX to Bounding Cylinder.
The Codes is below:
'=======================================
Option Strict Off
Imports System
Imports System.Math
Imports NXOpen
Imports NXOpen.UF
Imports NXOpenUI
Module Module2
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Sub Main()
Dim ufs As UFSession = UFSession.GetUFSession()
Dim displayPart As Part = theSession.Parts.Display
Dim lw As ListingWindow = theSession.ListingWindow
lw.Open()
Dim bbox(5) As Double
Dim dblAcc_Value(11) As Double
Dim dblMass_Props(46) As Double
Dim dblStats(12) As Double
Dim strOutput As String
Dim boundX As Double
Dim boundY As Double
Dim boundZ As Double
'**********************************************************
'**********************************************************
'Dim s As Session = Session.GetSession()
Dim theUI As UI = UI.GetUI()
Dim thePartAttr As NXOpen.Tag = NXOpen.Tag.Null
'**********************************************************
'**********************************************************
Dim minCorner(2) As Double
Dim boxDirections(2, 2) As Double
Dim boxDistances(2) As Double
Dim useACS As Boolean = False
Dim dirX As New Vector3d(1, 0, 0)
Dim dirY As New Vector3d(0, 1, 0)
Dim dirZ As New Vector3d(0, 0, 1)
Dim solid1 As Body
If SelectSolid("Select solid", solid1) = Selection.Response.Cancel Then
Return
End If
Dim tagList(0) As NXOpen.Tag
tagList(0) = solid1.Tag
Dim myCsys As CoordinateSystem = Nothing
If SelectCSYS("Select a saved CSYS, 'OK' to use ACS", myCsys) = Selection.Response.Cancel Then
Exit Sub
End If
If IsNothing(myCsys) Then
useACS = True
dirX.X = 1
dirX.Y = 0
dirX.Z = 0
dirY.X = 0
dirY.Y = 1
dirY.Z = 0
dirZ.X = 0
dirZ.Y = 0
dirZ.Z = 1
Else
With myCsys.Orientation.Element
dirX.X = .Xx
dirX.Y = .Xy
dirX.Z = .Xz
dirY.X = .Yx
dirY.Y = .Yy
dirY.Z = .Yz
dirZ.X = .Zx
dirZ.Y = .Zy
dirZ.Z = .Zz
End With
End If
'get volume
dblAcc_Value(0) = 0.999
'AskMassProps3d(in_Tags(),in_num_objs,in_type,in_units,in_density,in_accuracy,in_accuracy_values(),out_mass_props(),out_stats())
ufs.Modl.AskMassProps3d(tagList, 1, 1, 1, 0.0375, 1, dblAcc_Value, dblMass_Props, dblStats)
strOutput = "Surface Area: " & dblMass_Props(0) & vbCrLf
strOutput = strOutput & "Volume: " & dblMass_Props(1) & vbCrLf
strOutput = strOutput & "Mass: " & dblMass_Props(2) & vbCrLf
strOutput = strOutput & "COG: " & dblMass_Props(3) & ", " & dblMass_Props(4) & ", " & dblMass_Props(5) & vbCrLf
strOutput = strOutput & "Density: " & dblMass_Props(46)
If useACS Then
'get solid body bounding box extents aligned to absolute csys
ufs.Modl.AskBoundingBox(solid1.Tag, bbox)
boundX = bbox(3) - bbox(0)
boundY = bbox(4) - bbox(1)
boundZ = bbox(5) - bbox(2)
Else
'get solid body bounding box extents aligned to work csys (pass null tag to use work csys)
ufs.Modl.AskBoundingBoxAligned(solid1.Tag, myCsys.Tag, expand:=False, min_corner:=minCorner, directions:=boxDirections, distances:=boxDistances)
boundX = boxDistances(0)
boundY = boxDistances(1)
boundZ = boxDistances(2)
End If
'***********************************************************
Dim X As String
'**********************************************************
boundX = FormatNumber(boundX, 3) + 0.50
boundY = FormatNumber(boundy, 3) + 0.50
boundZ = FormatNumber(boundz, 3) + 0.50
'***********************************************************
'**********************************************************
'**********************************************************
ufs.Attr.AskPartAttribute(thePartAttr)
If thePartAttr <> Tag.Null Then
Dim type As Int32 = UFConstants.UF_ATTR_any
Dim title As String = "BoundType"
Dim value As String = "B"
Dim realtype As Int32
ufs.Attr.FindAttribute(thePartAttr, type, title, realtype)
If realtype <> 0 Then
If value <> "B" Then
If boundX <= boundY Then
If boundY <= boundZ Then
If boundZ >= boundX Then
'**********************************************************
AttributeLength("SizeX", boundX )
AttributeLength("SizeY", boundY )
AttributeLength("SizeZ", boundZ )
'**********************************************************
End If
End If
End If
If boundX <= boundY Then
If boundY >= boundZ Then
If boundZ >= boundX Then
'**********************************************************
AttributeLength("SizeX", boundX )
AttributeLength("SizeY", boundZ )
AttributeLength("SizeZ", boundY )
'**********************************************************
End If
End If
End If
If boundX = boundY Then
If boundX < boundZ Then
'**********************************************************
AttributeLength("SizeX", boundX )
AttributeLength("SizeY", boundY )
AttributeLength("SizeZ", boundZ )
'**********************************************************
End If
End If
If boundX >= boundY Then
If boundY <= boundZ Then
If boundZ >= boundX Then
'**********************************************************
AttributeLength("SizeX", boundY )
AttributeLength("SizeY", boundX )
AttributeLength("SizeZ", boundZ )
'**********************************************************
End If
End If
End If
If boundX >= boundY Then
If boundY <= boundZ Then
If boundZ <= boundX Then
'**********************************************************
AttributeLength("SizeX", boundY )
AttributeLength("SizeY", boundZ )
AttributeLength("SizeZ", boundX )
'**********************************************************
End If
End If
End If
If boundY = boundZ Then
If boundY <= boundX Then
'**********************************************************
AttributeLength("SizeX", boundY )
AttributeLength("SizeY", boundZ )
AttributeLength("SizeZ", boundX )
'**********************************************************
End If
End If
If boundX >= boundY Then
If boundY >= boundZ Then
If boundZ <= boundX Then
'**********************************************************
AttributeLength("SizeX", boundZ )
AttributeLength("SizeY", boundY )
AttributeLength("SizeZ", boundX )
'**********************************************************
End If
End If
End If
If boundX >= boundZ Then
If boundY >= boundZ Then
If boundY >= boundX Then
'**********************************************************
AttributeLength("SizeX", boundZ )
AttributeLength("SizeY", boundX )
AttributeLength("SizeZ", boundY )
'**********************************************************
End If
End If
End If
If boundX = boundZ Then
If boundY >= boundX Then
'**********************************************************
AttributeLength("SizeX", boundX )
AttributeLength("SizeY", boundZ )
AttributeLength("SizeZ", boundY )
'**********************************************************
End If
End If
'**********************************************************
'**********************************************************
Else
'**********************************************************
Dim Dia As Double = Sqrt((boundX * boundX) + (boundY * boundY))
AttributeLength("SizeX", Dia )
AttributeLength("SizeY", "0" )
AttributeLength("SizeZ", boundZ )
'**********************************************************
End If
End If
End If
'**********************************************************
'***********************************************************
AttributeTimeStamp()
workPart.SetUserAttribute("kali", -1, "x" , Update.Option.Now)
End Sub
'**********************************************************
Function SelectSolid(ByVal prompt As String, ByRef selObj As TaggedObject) As Selection.Response
Dim theUI As UI = UI.GetUI
Dim title As String = "Select a solid body"
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(0) As Selection.MaskTriple
With selectionMask_array(0)
.Type = UFConstants.UF_solid_type
.SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_BODY
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
'*******************
Function SelectCSYS(ByVal prompt As String, ByRef csysObj As CoordinateSystem) As Selection.Response
Dim theUI As UI = UI.GetUI
Dim title As String = prompt
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(0) As Selection.MaskTriple
With selectionMask_array(0)
.Type = UFConstants.UF_coordinate_system_type
.Subtype = UFConstants.UF_all_subtype
End With
Dim resp As Selection.Response = theUI.SelectionManager.SelectTaggedObject(prompt, _
title, scope, selAction, _
includeFeatures, keepHighlighted, selectionMask_array, _
csysObj, cursor)
If resp = Selection.Response.ObjectSelected OrElse _
resp = Selection.Response.ObjectSelectedByName OrElse _
resp = Selection.Response.Ok Then
Return Selection.Response.Ok
Else
Return Selection.Response.Cancel
End If
End Function
Sub AttributeLength(ByVal theName As String, ByVal theLength As String)
Dim objects1(0) As NXObject
objects1(0) = workPart
Dim attributePropertiesBuilder1 As AttributePropertiesBuilder
attributePropertiesBuilder1 = theSession.AttributeManager.CreateAttributePropertiesBuilder(workPart, objects1, AttributePropertiesBuilder.OperationType.None)
With attributePropertiesBuilder1
.IsArray = False
.DataType = AttributePropertiesBaseBuilder.DataTypeOptions.Number
.SetAttributeObjects(objects1)
If workPart.PartUnits = BasePart.Units.Inches Then
.Units = "Inch"
Else
.Units = "Millimeter"
End If
.Category = "BoundingBox"
.Title = theName
.NumberValue = theLength
Dim nXObject1 As NXObject
nXObject1 = .Commit()
End With
attributePropertiesBuilder1.Destroy()
End Sub
Sub AttributeDirection(ByVal theName As String, ByVal theDirection As Double)
Dim objects6(0) As NXObject
objects6(0) = workPart
Dim attributePropertiesBuilder2 As AttributePropertiesBuilder
attributePropertiesBuilder2 = theSession.AttributeManager.CreateAttributePropertiesBuilder(workPart, objects6, AttributePropertiesBuilder.OperationType.None)
With attributePropertiesBuilder2
.IsArray = False
.DataType = AttributePropertiesBaseBuilder.DataTypeOptions.Number
.SetAttributeObjects(objects6)
.Category = "BoundingBox"
.Title = theName
.Units = ""
.NumberValue = theDirection
Dim nXObject4 As NXObject
nXObject4 = attributePropertiesBuilder2.Commit()
End With
attributePropertiesBuilder2.Destroy()
End Sub
Sub AttributeTimeStamp()
Dim myDateTime As DateTime = Now
Dim objects11(0) As NXObject
objects11(0) = workPart
Dim attributePropertiesBuilder3 As AttributePropertiesBuilder
attributePropertiesBuilder3 = theSession.AttributeManager.CreateAttributePropertiesBuilder(workPart, objects11, AttributePropertiesBuilder.OperationType.None)
With attributePropertiesBuilder3
.IsArray = False
.DataType = AttributePropertiesBaseBuilder.DataTypeOptions.Date
.Category = "BoundingBox"
.Title = "TimeStamp"
.DateValue.DateItem.Day = myDateTime.Day - 1
.DateValue.DateItem.Month = myDateTime.Month - 1
.DateValue.DateItem.Year = myDateTime.Year.ToString
.DateValue.DateItem.Time = myDateTime.ToString("HH:mm:ss")
'("HH:mm:ss")
.SetAttributeObjects(objects11)
Dim nXObject7 As NXObject
nXObject7 = .Commit()
End With
attributePropertiesBuilder3.Destroy()
End Sub
Public Function GetUnloadOption(ByVal dummy As String) As Integer
'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
'-------------------------------
End Function
End Module
My Problem is:
- When I Change attribute BoundType to B value, The dimension cylinder diameter did not change to the Block mode (LengthxWidthxHeight).
- I still look for the way how to add Ø in font of Diameter value.
Anybody has doing this well, please help me for the codes.![[peace] [peace] [peace]](/data/assets/smilies/peace.gif)
Thank you.
NXExplorer
I am interested with thread561-366113
From that great code by COWSKI, I try to make assumption for Cylinder Diameter from base rectangle,
that Diameter Value with Pythagoras Law :
Diameter = Sqrt((boundX) ^ 2 + (boundY) ^ 2)
I have set the attribute for triggering the something like BoundType, B or C (Block or Cylinder). Also for the purpose of Inventory, The Block Size always X size smaller then Y size, and Y size smaller than Z size. But the point in this thread is about Bounding BOX to Bounding Cylinder.

The Codes is below:
'=======================================
Option Strict Off
Imports System
Imports System.Math
Imports NXOpen
Imports NXOpen.UF
Imports NXOpenUI
Module Module2
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Sub Main()
Dim ufs As UFSession = UFSession.GetUFSession()
Dim displayPart As Part = theSession.Parts.Display
Dim lw As ListingWindow = theSession.ListingWindow
lw.Open()
Dim bbox(5) As Double
Dim dblAcc_Value(11) As Double
Dim dblMass_Props(46) As Double
Dim dblStats(12) As Double
Dim strOutput As String
Dim boundX As Double
Dim boundY As Double
Dim boundZ As Double
'**********************************************************
'**********************************************************
'Dim s As Session = Session.GetSession()
Dim theUI As UI = UI.GetUI()
Dim thePartAttr As NXOpen.Tag = NXOpen.Tag.Null
'**********************************************************
'**********************************************************
Dim minCorner(2) As Double
Dim boxDirections(2, 2) As Double
Dim boxDistances(2) As Double
Dim useACS As Boolean = False
Dim dirX As New Vector3d(1, 0, 0)
Dim dirY As New Vector3d(0, 1, 0)
Dim dirZ As New Vector3d(0, 0, 1)
Dim solid1 As Body
If SelectSolid("Select solid", solid1) = Selection.Response.Cancel Then
Return
End If
Dim tagList(0) As NXOpen.Tag
tagList(0) = solid1.Tag
Dim myCsys As CoordinateSystem = Nothing
If SelectCSYS("Select a saved CSYS, 'OK' to use ACS", myCsys) = Selection.Response.Cancel Then
Exit Sub
End If
If IsNothing(myCsys) Then
useACS = True
dirX.X = 1
dirX.Y = 0
dirX.Z = 0
dirY.X = 0
dirY.Y = 1
dirY.Z = 0
dirZ.X = 0
dirZ.Y = 0
dirZ.Z = 1
Else
With myCsys.Orientation.Element
dirX.X = .Xx
dirX.Y = .Xy
dirX.Z = .Xz
dirY.X = .Yx
dirY.Y = .Yy
dirY.Z = .Yz
dirZ.X = .Zx
dirZ.Y = .Zy
dirZ.Z = .Zz
End With
End If
'get volume
dblAcc_Value(0) = 0.999
'AskMassProps3d(in_Tags(),in_num_objs,in_type,in_units,in_density,in_accuracy,in_accuracy_values(),out_mass_props(),out_stats())
ufs.Modl.AskMassProps3d(tagList, 1, 1, 1, 0.0375, 1, dblAcc_Value, dblMass_Props, dblStats)
strOutput = "Surface Area: " & dblMass_Props(0) & vbCrLf
strOutput = strOutput & "Volume: " & dblMass_Props(1) & vbCrLf
strOutput = strOutput & "Mass: " & dblMass_Props(2) & vbCrLf
strOutput = strOutput & "COG: " & dblMass_Props(3) & ", " & dblMass_Props(4) & ", " & dblMass_Props(5) & vbCrLf
strOutput = strOutput & "Density: " & dblMass_Props(46)
If useACS Then
'get solid body bounding box extents aligned to absolute csys
ufs.Modl.AskBoundingBox(solid1.Tag, bbox)
boundX = bbox(3) - bbox(0)
boundY = bbox(4) - bbox(1)
boundZ = bbox(5) - bbox(2)
Else
'get solid body bounding box extents aligned to work csys (pass null tag to use work csys)
ufs.Modl.AskBoundingBoxAligned(solid1.Tag, myCsys.Tag, expand:=False, min_corner:=minCorner, directions:=boxDirections, distances:=boxDistances)
boundX = boxDistances(0)
boundY = boxDistances(1)
boundZ = boxDistances(2)
End If
'***********************************************************
Dim X As String
'**********************************************************
boundX = FormatNumber(boundX, 3) + 0.50
boundY = FormatNumber(boundy, 3) + 0.50
boundZ = FormatNumber(boundz, 3) + 0.50
'***********************************************************
'**********************************************************
'**********************************************************
ufs.Attr.AskPartAttribute(thePartAttr)
If thePartAttr <> Tag.Null Then
Dim type As Int32 = UFConstants.UF_ATTR_any
Dim title As String = "BoundType"
Dim value As String = "B"
Dim realtype As Int32
ufs.Attr.FindAttribute(thePartAttr, type, title, realtype)
If realtype <> 0 Then
If value <> "B" Then
If boundX <= boundY Then
If boundY <= boundZ Then
If boundZ >= boundX Then
'**********************************************************
AttributeLength("SizeX", boundX )
AttributeLength("SizeY", boundY )
AttributeLength("SizeZ", boundZ )
'**********************************************************
End If
End If
End If
If boundX <= boundY Then
If boundY >= boundZ Then
If boundZ >= boundX Then
'**********************************************************
AttributeLength("SizeX", boundX )
AttributeLength("SizeY", boundZ )
AttributeLength("SizeZ", boundY )
'**********************************************************
End If
End If
End If
If boundX = boundY Then
If boundX < boundZ Then
'**********************************************************
AttributeLength("SizeX", boundX )
AttributeLength("SizeY", boundY )
AttributeLength("SizeZ", boundZ )
'**********************************************************
End If
End If
If boundX >= boundY Then
If boundY <= boundZ Then
If boundZ >= boundX Then
'**********************************************************
AttributeLength("SizeX", boundY )
AttributeLength("SizeY", boundX )
AttributeLength("SizeZ", boundZ )
'**********************************************************
End If
End If
End If
If boundX >= boundY Then
If boundY <= boundZ Then
If boundZ <= boundX Then
'**********************************************************
AttributeLength("SizeX", boundY )
AttributeLength("SizeY", boundZ )
AttributeLength("SizeZ", boundX )
'**********************************************************
End If
End If
End If
If boundY = boundZ Then
If boundY <= boundX Then
'**********************************************************
AttributeLength("SizeX", boundY )
AttributeLength("SizeY", boundZ )
AttributeLength("SizeZ", boundX )
'**********************************************************
End If
End If
If boundX >= boundY Then
If boundY >= boundZ Then
If boundZ <= boundX Then
'**********************************************************
AttributeLength("SizeX", boundZ )
AttributeLength("SizeY", boundY )
AttributeLength("SizeZ", boundX )
'**********************************************************
End If
End If
End If
If boundX >= boundZ Then
If boundY >= boundZ Then
If boundY >= boundX Then
'**********************************************************
AttributeLength("SizeX", boundZ )
AttributeLength("SizeY", boundX )
AttributeLength("SizeZ", boundY )
'**********************************************************
End If
End If
End If
If boundX = boundZ Then
If boundY >= boundX Then
'**********************************************************
AttributeLength("SizeX", boundX )
AttributeLength("SizeY", boundZ )
AttributeLength("SizeZ", boundY )
'**********************************************************
End If
End If
'**********************************************************
'**********************************************************
Else
'**********************************************************
Dim Dia As Double = Sqrt((boundX * boundX) + (boundY * boundY))
AttributeLength("SizeX", Dia )
AttributeLength("SizeY", "0" )
AttributeLength("SizeZ", boundZ )
'**********************************************************
End If
End If
End If
'**********************************************************
'***********************************************************
AttributeTimeStamp()
workPart.SetUserAttribute("kali", -1, "x" , Update.Option.Now)
End Sub
'**********************************************************
Function SelectSolid(ByVal prompt As String, ByRef selObj As TaggedObject) As Selection.Response
Dim theUI As UI = UI.GetUI
Dim title As String = "Select a solid body"
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(0) As Selection.MaskTriple
With selectionMask_array(0)
.Type = UFConstants.UF_solid_type
.SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_BODY
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
'*******************
Function SelectCSYS(ByVal prompt As String, ByRef csysObj As CoordinateSystem) As Selection.Response
Dim theUI As UI = UI.GetUI
Dim title As String = prompt
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(0) As Selection.MaskTriple
With selectionMask_array(0)
.Type = UFConstants.UF_coordinate_system_type
.Subtype = UFConstants.UF_all_subtype
End With
Dim resp As Selection.Response = theUI.SelectionManager.SelectTaggedObject(prompt, _
title, scope, selAction, _
includeFeatures, keepHighlighted, selectionMask_array, _
csysObj, cursor)
If resp = Selection.Response.ObjectSelected OrElse _
resp = Selection.Response.ObjectSelectedByName OrElse _
resp = Selection.Response.Ok Then
Return Selection.Response.Ok
Else
Return Selection.Response.Cancel
End If
End Function
Sub AttributeLength(ByVal theName As String, ByVal theLength As String)
Dim objects1(0) As NXObject
objects1(0) = workPart
Dim attributePropertiesBuilder1 As AttributePropertiesBuilder
attributePropertiesBuilder1 = theSession.AttributeManager.CreateAttributePropertiesBuilder(workPart, objects1, AttributePropertiesBuilder.OperationType.None)
With attributePropertiesBuilder1
.IsArray = False
.DataType = AttributePropertiesBaseBuilder.DataTypeOptions.Number
.SetAttributeObjects(objects1)
If workPart.PartUnits = BasePart.Units.Inches Then
.Units = "Inch"
Else
.Units = "Millimeter"
End If
.Category = "BoundingBox"
.Title = theName
.NumberValue = theLength
Dim nXObject1 As NXObject
nXObject1 = .Commit()
End With
attributePropertiesBuilder1.Destroy()
End Sub
Sub AttributeDirection(ByVal theName As String, ByVal theDirection As Double)
Dim objects6(0) As NXObject
objects6(0) = workPart
Dim attributePropertiesBuilder2 As AttributePropertiesBuilder
attributePropertiesBuilder2 = theSession.AttributeManager.CreateAttributePropertiesBuilder(workPart, objects6, AttributePropertiesBuilder.OperationType.None)
With attributePropertiesBuilder2
.IsArray = False
.DataType = AttributePropertiesBaseBuilder.DataTypeOptions.Number
.SetAttributeObjects(objects6)
.Category = "BoundingBox"
.Title = theName
.Units = ""
.NumberValue = theDirection
Dim nXObject4 As NXObject
nXObject4 = attributePropertiesBuilder2.Commit()
End With
attributePropertiesBuilder2.Destroy()
End Sub
Sub AttributeTimeStamp()
Dim myDateTime As DateTime = Now
Dim objects11(0) As NXObject
objects11(0) = workPart
Dim attributePropertiesBuilder3 As AttributePropertiesBuilder
attributePropertiesBuilder3 = theSession.AttributeManager.CreateAttributePropertiesBuilder(workPart, objects11, AttributePropertiesBuilder.OperationType.None)
With attributePropertiesBuilder3
.IsArray = False
.DataType = AttributePropertiesBaseBuilder.DataTypeOptions.Date
.Category = "BoundingBox"
.Title = "TimeStamp"
.DateValue.DateItem.Day = myDateTime.Day - 1
.DateValue.DateItem.Month = myDateTime.Month - 1
.DateValue.DateItem.Year = myDateTime.Year.ToString
.DateValue.DateItem.Time = myDateTime.ToString("HH:mm:ss")
'("HH:mm:ss")
.SetAttributeObjects(objects11)
Dim nXObject7 As NXObject
nXObject7 = .Commit()
End With
attributePropertiesBuilder3.Destroy()
End Sub
Public Function GetUnloadOption(ByVal dummy As String) As Integer
'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
'-------------------------------
End Function
End Module
My Problem is:
- When I Change attribute BoundType to B value, The dimension cylinder diameter did not change to the Block mode (LengthxWidthxHeight).
- I still look for the way how to add Ø in font of Diameter value.
Anybody has doing this well, please help me for the codes.
![[peace] [peace] [peace]](/data/assets/smilies/peace.gif)
Thank you.
NXExplorer