Points transformation
Points transformation
(OP)
Hello everybody,
I am using NX 9 and I have a doubt regarding the transformation of faces from 3d space to 2d space. Basically what I want to do is to transform each {x,y,z} point of a surface by projecting them to the ZX plane doing the following transformation:
{x,y,z} --> {x, 0, sqrt(y^2+z^2)}
The reason why I am doing this is because I want to find a way to automatically generate 2d axisymmetric models.
I have tried to do this through menu>edit>transform but I can't see how this can be done.
What would be the best procedure to do this?
Many thanks.
J
I am using NX 9 and I have a doubt regarding the transformation of faces from 3d space to 2d space. Basically what I want to do is to transform each {x,y,z} point of a surface by projecting them to the ZX plane doing the following transformation:
{x,y,z} --> {x, 0, sqrt(y^2+z^2)}
The reason why I am doing this is because I want to find a way to automatically generate 2d axisymmetric models.
I have tried to do this through menu>edit>transform but I can't see how this can be done.
What would be the best procedure to do this?
Many thanks.
J





RE: Points transformation
We only run on NX7.5 here, so I can't help very much
Go into your command finder and enter project points and see where that guides you
RE: Points transformation
John R. Baker, P.E.
Product 'Evangelist'
Product Engineering Software
Siemens PLM Software Inc.
Industry Sector
Cypress, CA
Siemens PLM:
UG/NX Museum:
To an Engineer, the glass is twice as big as it needs to be.
RE: Points transformation
You just run the journal, it will ask you to pick a face and then the points should appear.
Option Strict Off
Imports System
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.UF
Imports NXOpenUI
Module Module1
Dim theSession As Session = Session.GetSession()
Dim theUISession As UI = UI.GetUI
Dim theUfSession As UFSession = UFSession.GetUFSession()
Dim workPart As Part = theSession.Parts.Work
Dim XYZpoint(120) As Point
Dim XZpoint(120) As Point
Dim i As Integer
Dim Upitch As Double = 0.1
Dim Vpitch As Double = 0.1
Sub Main()
Dim pickFace As Face
Dim selectionFaces() As TaggedObject
Dim lstSelFaces As List(Of Face) = New List(Of Face)
SelectAFace("select a face", pickFace)
lstSelFaces.Add(pickface)
For Each obj As Face In lstSelFaces
i = 0
For Vstep As Double = 0.0 To 1 Step Vpitch
For Ustep As Double = 0 To 1 Step Upitch
'Display a point on the original face
XYZpoint(i) = CreatePointOnSurf(Ustep, Vstep, obj)
Dim poipos(2) As Double
poipos(0) = XYZpoint(i).Coordinates.X
poipos(1) = XYZpoint(i).Coordinates.y
poipos(2) = XYZpoint(i).Coordinates.z
Dim poicolour As New NXOpen.UF.UFObj.DispProps()
poicolour.color = 216
theUfSession.Disp.DisplayTemporaryPoint(Tag.Null, UFDisp.ViewType.UseWorkView, poipos, poicolour, UFDisp.PolyMarker.Asterisk)
'Transform the point through the formula: {x,y,z} --> {x, 0, sqrt(y^2+z^2)}
Dim newpos(2) As Double
newpos(0) = poipos(0)
newpos(1) = 0
newpos(2) = System.Math.Sqrt((poipos(1) * poipos(1)) + (poipos(2) * poipos(2)))
poicolour.color = 36
theUfSession.Disp.DisplayTemporaryPoint(Tag.Null, UFDisp.ViewType.UseWorkView, newpos, poicolour, UFDisp.PolyMarker.Asterisk)
i += 1
Next
Next
Next
msgbox("Tranformed Points Total = :" & i - 2)
For Each obj As Face In lstSelFaces
obj.UnHighlight()
Next
End Sub
Public Function CreatePointOnSurf(ByVal Uparam As Double, ByVal Vparam As Double, ByVal face1 As face) As Point
Dim scalar1 As Scalar
scalar1 = WorkPart.Scalars.CreateScalar(Uparam, Scalar.DimensionalityType.None, SmartObject.UpdateOption.AfterModeling)
Dim scalar2 As Scalar
scalar2 = WorkPart.Scalars.CreateScalar(Vparam, Scalar.DimensionalityType.None, SmartObject.UpdateOption.AfterModeling)
Dim point1 As Point
point1 = WorkPart.Points.CreatePoint(face1, scalar1, scalar2, SmartObject.UpdateOption.AfterModeling)
Return point1
End Function
Function SelectAFace(ByVal prompt As String, ByRef selObj As Face) As Selection.Response
Dim theUI As UI = UI.GetUI
Dim title As String = "Select a face"
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.AnyInAssembly
Dim selectionMask_array(0) As Selection.MaskTriple
With selectionMask_array(0)
.Type = UFConstants.UF_solid_type
.SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_ANY_FACE
End With
Dim resp As Selection.Response = theUI.SelectionManager.SelectObject(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
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
RE: Points transformation
CODE -->
Option Strict Off Imports System Imports NXOpen Imports NXOpen.UF Imports NXOpenUI Module EdgeProjection1 Dim s As Session = Session.GetSession() Dim ui As UI = UI.GetUI Dim ufs As UFSession = UFSession.GetUFSession() Dim workPart As Part = s.Parts.Work Sub Main() Dim face1 As Face = Nothing Dim lstSelFaces As List(Of Face) = New List(Of Face) Dim response1 As Selection.Response = Selection.Response.Cancel Dim pnt1(2) As Double Dim junk3(2) As Double Dim junk1 As Double = Nothing Dim ArrayOfPoints(10) As Point start1: response1 = SelectAFace("select a face", face1) If response1 = Selection.Response.Back Or response1 = Selection.Response.Cancel Then GoTo end1 Dim edges(-1) As Edge edges = face1.GetEdges Dim temptag As Tag = Tag.Null Dim parm1 As Double = Nothing For Each e1 As Edge In edges For i As Integer = 0 To 10 parm1 = i / 10.0 ufs.Modl.AskCurveProps(e1.Tag, parm1, pnt1, junk3, junk3, junk3, junk1, junk1) Dim projpnt13d As Point3d = New Point3d(pnt1(0), 0.0, _ Math.Sqrt(pnt1(1) * pnt1(1) + _ pnt1(2) * pnt1(2))) ArrayOfPoints(i) = workPart.Points.CreatePoint(projpnt13d) Next CreateStudioSplineThruPoints(ArrayOfPoints) Next GoTo start1 end1: End Sub Public Sub CreateStudioSplineThruPoints(ByRef points() As Point) Dim markId9 As Session.UndoMarkId markId9 = s.SetUndoMark(Session.MarkVisibility.Visible, "Studio Spline Thru Points") Dim Pcount As Integer = points.Length - 1 Dim nullFeatures_StudioSpline As Features.StudioSpline = Nothing Dim studioSplineBuilder1 As Features.StudioSplineBuilderEx studioSplineBuilder1 = workPart.Features.CreateStudioSplineBuilderEx(nullFeatures_StudioSpline) studioSplineBuilder1.Degree = 3 studioSplineBuilder1.IsPeriodic = False Dim knots1(-1) As Double studioSplineBuilder1.SetKnots(knots1) Dim parameters1(-1) As Double studioSplineBuilder1.SetParameters(parameters1) Dim nullDirection As Direction = Nothing Dim nullScalar As Scalar = Nothing Dim nullOffset As Offset = Nothing Dim geometricConstraintData(Pcount) As Features.GeometricConstraintData For ii As Integer = 0 To Pcount geometricConstraintData(ii) = studioSplineBuilder1.ConstraintManager.CreateGeometricConstraintData() geometricConstraintData(ii).Point = points(ii) geometricConstraintData(ii).AutomaticConstraintDirection = Features.GeometricConstraintData.ParameterDirection.Iso geometricConstraintData(ii).AutomaticConstraintType = Features.GeometricConstraintData.AutoConstraintType.None geometricConstraintData(ii).TangentDirection = nullDirection geometricConstraintData(ii).TangentMagnitude = nullScalar geometricConstraintData(ii).Curvature = nullOffset geometricConstraintData(ii).CurvatureDerivative = nullOffset geometricConstraintData(ii).HasSymmetricModelingConstraint = False Next ii studioSplineBuilder1.ConstraintManager.SetContents(geometricConstraintData) Dim feature1 As Features.Feature feature1 = studioSplineBuilder1.CommitFeature() studioSplineBuilder1.Destroy() End Sub Function SelectAFace(ByVal prompt As String, ByRef selObj As Face) As Selection.Response Dim title As String = "Select a face" 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.AnyInAssembly Dim selectionMask_array(0) As Selection.MaskTriple With selectionMask_array(0) .Type = UFConstants.UF_solid_type .SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_ANY_FACE End With Dim resp As Selection.Response = ui.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 Public Function GetUnloadOption(ByVal dummy As String) As Integer '----Other unload options------- 'Unloads the image immediately after execution within NX GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately End Function End ModuleFrank Swinkels
RE: Points transformation
I have a compile error in line 15 of FrankSwinks' journal (Type List is not defined). What could this be? Sorry if the question sounds stupid but I typically write my code in C# and therefore my VB knowledge is extremely limited (but I will work on this :)).
Thanks again!
RE: Points transformation
Imports System.Collections.Generic
OR
fully qualify the list variable
Dim lstSelFaces As Collections.Generic.List(Of Face) = New Collections.Generic.List(Of Face)
www.nxjournaling.com
RE: Points transformation
Dim lstSelFaces As List(Of Face) = New List(Of Face)
When I wrote the journal I started with the existing previous journal. It does nothing in my journal.
Frank Swinkels