How to get point and vector selected in blockstyler ?

Hi,

In the following code I tried to create point and axis after selecting with block styler

But I have a problem to terminate the 2 lines above

Dim thePoint As Point = s.Parts.Work.Points.CreatePoint(
Dim revolve_axis As Axis = s.Parts.Work.Axes.CreateAxis(

Thanks in advance

Regards

Didier
___________________________________________________________


Option Strict Off
Imports NXOpen
Imports NXOpen.BlockStyler

Public Class Dialog
Private Shared s As Session
Private Shared theUI As UI
Private theDlxFileName As String = "axis_and_point.dlx"
Private theDialog As BlockStyler.BlockDialog

Private block_axe As NXOpen.BlockStyler.SpecifyAxis '
Dim propList As PropertyList = Nothing

Public Sub New()
Try
s = Session.GetSession()
theUI = UI.GetUI()
theDialog = theUI.CreateDialog(theDlxFileName)
theDialog.AddApplyHandler(AddressOf apply_cb)
theDialog.AddInitializeHandler(AddressOf initialize_cb)
theDialog.AddDialogShownHandler(AddressOf dialogShown_cb)
theDialog.AddUpdateHandler(AddressOf update_cb)
theDialog.AddOkHandler(AddressOf ok_cb)

Catch ex As Exception
Throw ex
End Try
End Sub
Public Sub initialize_cb()
Try
Catch ex As Exception
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
End Try
End Sub
Public Sub dialogShown_cb()
Try
Catch ex As Exception
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
End Try
End Sub
Public Sub Show()
Try
theDialog.Show()
block_axe = theDialog.TopBlock.FindBlock("axis0")

Catch ex As Exception
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
End Try
End Sub
Public Sub Dispose()
If theDialog IsNot Nothing Then
theDialog.Dispose()
theDialog = Nothing
End If
End Sub
Public Function update_cb(ByVal block As UIBlock) As Integer
Dim propList As PropertyList = Nothing

Try

Catch ex As Exception
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
End Try

update_cb = 0
End Function
Public Function apply_cb() As Integer
Dim errorCode As Integer = 0
Try

Catch ex As Exception
errorCode = 1
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
End Try
apply_cb = errorCode
End Function
Public Function ok_cb() As Integer
Dim errorCode as Integer = 0
Try
propList = block_axe.GetProperties

Dim thePoint As Point = s.Parts.Work.Points.CreatePoint(
Dim revolve_axis As Axis = s.Parts.Work.Axes.CreateAxis(

Catch ex As Exception
errorCode = 1
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
End Try
ok_cb = errorCode
End Function

End Class

You should add the Block point and Block vector. Before use PropertyList to get property of the point and vector.
like a (sorry, i work in c++):

else if(block == point0)
{
PropertyList *p1 = point0->GetProperties();
Point3d A = p1->GetPoint("Point");
Point *point1 = workPart->Points()->CreatePoint(A);
}

NX 11, C/C++ or VB (sometimes)

Hi Kinrim,

First of all, thanks for your help

OK, I have added the block, but I have an error during execution at the following line

thePoint3d = propList.GetPoint("Point")

===> error message is: Invalid property name for the block

and in the syslog I can see:

+++ Property "Point" does not exist for block name "axis0"

So, how to find the right name property ?

Regards

Didier


block_axis = theDialog.TopBlock.FindBlock("axis0")
propList = block_axis.GetProperties

Dim thePoint3d As Point3d
thePoint3d = propList.GetPoint("Point")
s.Parts.Work.Points.CreatePoint(thePoint3d)

Your code is trying to retrieve a point from the axis block. Shouldn't it get an axis from the axis block and a point from the point block?

I create a sample UI

'------------------------------------------------------------------------------
'Callback Name: update_cb
'------------------------------------------------------------------------------
Public Function update_cb(ByVal block As NXOpen.BlockStyler.UIBlock) As Integer
Try

If block Is point0 Then
'---- Enter your code here -----

ElseIf block Is axis0 Then
'---- Enter your code here -----

End If

Catch ex As Exception

'---- Enter your exception handling code here -----
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
End Try
update_cb = 0
End Function

There are two block: point0 and axis0 - a names property. If you want to create only axis, in your code will be only block axis. The block axis consist of point and direction. You should get this property from block and create axis. See information about creating axis in VB.

NX 11, C/C++ or VB (sometimes)

Hi,

I tried also and founded the same problem

Is it possible to send an image for explanation

Hi,
You didn't understand my problem.

I want to find the syntax to get the right propertries from point0 ans axis0 to create the point and the axis.

Example on your computer: ...\UGOPEN\SampleNXOpenApplications\.NET\BlockStyler\UDB_CreateCylinder\
where:
'Get the point
Dim pointPropertyList As PropertyList = point0.GetProperties()
Dim point1 As Point3d = pointPropertyList.GetPoint("Point")
pointPropertyList.Dispose()
pointPropertyList = Nothing

Dim vectorPropertyList As PropertyList = vector0.GetProperties()
Dim Vector As Vector3d = vectorPropertyList.GetVector("Vector")
vectorPropertyList.Dispose()
vectorPropertyList = Nothing

and if you create axis block, you should to use axis0 instead point0 and vector0 (axis0.GetProperties()).
I hope this is right and you will succeed.

NX 11, C/C++ or VB (sometimes)

Hi,
Thanks à lot, I found it