Ehaviv
Computer
- Jul 2, 2003
- 1,012
Hi
This journal work OK when I removed the Resize plane code segment
and its also run with it but the orientation and location
of the plane allwase in the abs coord.
can someomne help correct it
Thank you in advanced
This journal work OK when I removed the Resize plane code segment
and its also run with it but the orientation and location
of the plane allwase in the abs coord.
can someomne help correct it
Thank you in advanced
Code:
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpenUI
Module create_and_resize_plane
Sub Main
Dim theSession As Session = Session.GetSession()
Dim ufs As UFSession = UFSession.GetUFSession()
create_plane( )
End Sub
'*********************************************************************
Sub create_plane( )
' ****** Create Datum plane ******
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
Dim ufs As UFSession = UFSession.GetUFSession()
Dim wcs_origin As Point3d = workPart.WCS.Origin
Dim wcs_matrix3x3 As Matrix3x3 = workPart.WCS.CoordinateSystem.Orientation.Element
Dim featdatum_tag As Tag
Dim featdatum_obj As NXObject
Dim xyplane As DatumPlane
xyplane = workPart.Datums.CreateFixedDatumPlane(wcs_origin,wcs_matrix3x3)
xyplane.SetName("_XY_")
ufs.Modl.AskObjectFeat(xyplane.Tag,featdatum_tag)
featdatum_obj = NXOpen.Utilities.NXObjectManager.Get(featdatum_tag)
Dim xy_PlaneFeat As Features.DatumPlaneFeature = CType(featdatum_obj,Features.DatumPlaneFeature)
xy_PlaneFeat.SetName("_XY_")
'==================== Resize plane start ========================
Dim nullFeature As NXOpen.Features.Feature = Nothing
Dim resizePlaneBuilder1 As Features.ResizePlaneBuilder
resizePlaneBuilder1 = workPart.Features.CreateResizePlaneBuilder(nullFeature)
resizePlaneBuilder1.Plane.Value = xyplane
resizePlaneBuilder1.ResizeDuringUpdate = False
Dim d As Double = 3.0
Dim p As Double = 1.0
Dim n As Double = -1.0
d = d/2
Dim corners As Point3d() = {New Point3d(n*d, n*d, 0.0),New Point3d(p*d, n*d, 0.0), _
New Point3d(p*d, p*d, 0.0),New Point3d(n*d, p*d, 0.0)}
resizePlaneBuilder1.SetCornerPoints(corners)
resizePlaneBuilder1.Commit()
resizePlaneBuilder1.Destroy()
'====================== Resize plane end ======================
Dim Xdir As New Point3d(1,0,0)
Xdir = WCS2Abs(Xdir)
Dim Xaxis As DatumAxis
Xaxis = workPart.Datums.CreateFixedDatumAxis(wcs_origin,Xdir)
Xaxis.SetName("_X_")
ufs.Modl.AskObjectFeat(Xaxis.Tag,featdatum_tag)
featdatum_obj = NXOpen.Utilities.NXObjectManager.Get(featdatum_tag)
Dim x_AxisFeat As Features.DatumAxisFeature = CType(featdatum_obj,Features.DatumAxisFeature)
x_AxisFeat.SetName("_X_")
Dim Ydir As New Point3d(0,1,0)
Ydir = WCS2Abs(Ydir)
Dim Yaxis As DatumAxis
Yaxis = workPart.Datums.CreateFixedDatumAxis(wcs_origin,Ydir)
Yaxis.SetName("_Y_")
ufs.Modl.AskObjectFeat(Yaxis.Tag,featdatum_tag)
featdatum_obj = NXOpen.Utilities.NXObjectManager.Get(featdatum_tag)
Dim y_AxisFeat As Features.DatumAxisFeature = CType(featdatum_obj,Features.DatumAxisFeature)
y_AxisFeat.SetName("_Y_")
End Sub
'---------------------------------------------------------------------
Function WCS2Abs(ByVal inPt As Point3d) As Point3d
Dim ufs As UFSession = UFSession.GetUFSession()
Dim pt1(2), pt2(2) As Double
pt1(0) = inPt.X
pt1(1) = inPt.Y
pt1(2) = inPt.Z
ufs.Csys.MapPoint(UFConstants.UF_CSYS_ROOT_WCS_COORDS, pt1, UFConstants.UF_CSYS_ROOT_COORDS, pt2)
WCS2Abs.X = pt2(0)
WCS2Abs.Y = pt2(1)
WCS2Abs.Z = pt2(2)
End Function
'---------------------------------------------------------------------
Public Function GetUnloadOption(ByVal dummy As String) As Integer
'Unloads the image when the NX session terminates
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
End Function
'---------------------------------------------------------------------
End Module