NXOpen.tag cannot be converted to NXOpen.Face
NXOpen.tag cannot be converted to NXOpen.Face
(OP)
Dear Forum,
I am using NXOpen function theUfSession.Modl.CreateRevolved(objarray, {"0", "360"}, origin, vect, FeatureSigns.Nullsign, features) to create a revolved sheet body from a line in the xy-plane. Next I want to extract the face of this revolved and pass it into another function to create intersection of curves. How do I cast an NXOpen tag into an NXOpen face?
Thanks in advance.
I am using NXOpen function theUfSession.Modl.CreateRevolved(objarray, {"0", "360"}, origin, vect, FeatureSigns.Nullsign, features) to create a revolved sheet body from a line in the xy-plane. Next I want to extract the face of this revolved and pass it into another function to create intersection of curves. How do I cast an NXOpen tag into an NXOpen face?
Thanks in advance.





RE: NXOpen.tag cannot be converted to NXOpen.Face
www.nxjournaling.com
RE: NXOpen.tag cannot be converted to NXOpen.Face
CODE -->
Graham Inchley, Systems Developer, Sandvik Coromant. www.sandvik.com
HP EliteBook 8760w, Win7, 8GB. Developing in: Java | C | C# | KF
Production: NX6.0.5.3 MP5
Testing: NX8.5.3.3 MP4 64bit | NX9.0.2.5
RE: NXOpen.tag cannot be converted to NXOpen.Face
I am using the following function theUfSession.Modl.CreateRevolved(objarray, {"0", "360"}, origin, vect, FeatureSigns.Nullsign, features). The revolved surface is getting created but I am having problems casting the features(0) into a face. I've journaled the activity of taking the revolved sheet body and intersecting it with another sheet body to try and finding the casting.
Here's the snippet from the journal:
Dim bodyFeature1 As Features.BodyFeature = CType(workPart.Features.FindObject("REVOLVED(13)"), Features.BodyFeature)
Dim face5 As Face = CType(bodyFeature1.FindObject("FACE 67700 {(0,0,34) REVOLVED(13)}"), Face)
RE: NXOpen.tag cannot be converted to NXOpen.Face
It might be a bit easier if you create the revolve with a RevolveBuilder; this will give you a reference to the newly created revolve feature without messing about with tags.
www.nxjournaling.com
RE: NXOpen.tag cannot be converted to NXOpen.Face
theUfSession.Modl.CreateRevolved(objarray, {"0", "180"}, origin, vect, FeatureSigns.Nullsign, features)
Dim featName As String = Nothing
theUfSession.Modl.AskFeatName(features(0), featName)
Dim bodyFeature1 As Features.BodyFeature = CType(workPart.Features.FindObject(featName), Features.BodyFeature)
Dim hoop() As Face = bodyFeature1.GetFaces()
Dim TestIntersect As Features.IntersectionCurve
TestIntersect = Nothing
For iii As Integer = 0 To hoop.Count - 1
Try
TestIntersect = createIntersectionCurves(Airfoil, hoop(iii))
Exit For
Catch ex As Exception
If iii.Equals(hoop.Count - 1) Then
'Throw New Exception("Failed to Find Intersect of Radial Hoop with Airfoil")
Return Nothing
End If
End Try
Next
RE: NXOpen.tag cannot be converted to NXOpen.Face
CODE
Option Strict Off Imports System Imports NXOpen Module Module1 Dim theSession As Session = Session.GetSession() Dim workPart As Part = theSession.Parts.Work Sub Main() If IsNothing(theSession.Parts.Work) Then 'active part required Return End If Dim lw As ListingWindow = theSession.ListingWindow lw.Open() Const undoMarkName As String = "NXJ journal" Dim markId1 As Session.UndoMarkId markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName) 'create line to use in revolve feature Dim revolveLine As Line revolveLine = workPart.Curves.CreateLine(New Point3d(0, 25, 0), New Point3d(25, 25, 0)) 'revolve about absolute X vector Dim thePoint As Point = workPart.Points.CreatePoint(New Point3d(0, 0, 0)) Dim theDirection As Direction = workPart.Directions.CreateDirection(thePoint.Coordinates, New Vector3d(1, 0, 0), SmartObject.UpdateOption.WithinModeling) Dim axis1 As Axis axis1 = workPart.Axes.CreateAxis(thePoint, theDirection, SmartObject.UpdateOption.WithinModeling) 'create the revolve builder Dim revolveBuilder1 As Features.RevolveBuilder revolveBuilder1 = workPart.Features.CreateRevolveBuilder(Nothing) revolveBuilder1.Limits.StartExtend.Value.RightHandSide = "0" revolveBuilder1.Limits.EndExtend.Value.RightHandSide = "360" revolveBuilder1.BooleanOperation.Type = GeometricUtilities.BooleanOperation.BooleanType.Create revolveBuilder1.Tolerance = 0.001 revolveBuilder1.FeatureOptions.BodyType = GeometricUtilities.FeatureOptions.BodyStyle.Sheet revolveBuilder1.Axis = axis1 'create section for revolve builder Dim section1 As Section section1 = workPart.Sections.CreateSection(0.00095, 0.001, 0.5) section1.SetAllowedEntityTypes(Section.AllowTypes.OnlyCurves) section1.AllowSelfIntersection(False) Dim curves1(0) As IBaseCurve curves1(0) = revolveLine 'create curve rule Dim curveDumbRule1 As CurveDumbRule curveDumbRule1 = workPart.ScRuleFactory.CreateRuleBaseCurveDumb(curves1) 'create selection intent rule Dim rules1(0) As SelectionIntentRule rules1(0) = curveDumbRule1 Dim nullNXObject As NXObject = Nothing 'add our input line to the section section1.AddToSection(rules1, revolveLine, nullNXObject, nullNXObject, revolveLine.StartPoint, Section.Mode.Create, False) revolveBuilder1.Section = section1 'revolveBuilder1.ParentFeatureInternal = False Dim feature1 As Features.BodyFeature feature1 = revolveBuilder1.CommitFeature() revolveBuilder1.Destroy() 'report the feature faces lw.WriteLine(feature1.GetFeatureName & " contains: " & feature1.GetFaces.Length.ToString & " faces") Dim theFaces() As Face = feature1.GetFaces() For i As Integer = 0 To theFaces.Length - 1 lw.WriteLine(" face " & i.ToString & " color: " & theFaces(i).Color) lw.WriteLine(" face " & i.ToString & " layer: " & theFaces(i).Layer) lw.WriteLine(" face " & i.ToString & " area: " & FaceArea(theFaces(i)).ToString & " square inches") lw.WriteLine("") Next lw.Close() End Sub Function FaceArea(ByVal inputFace As Face) As Double Dim theFaceArea As Double Dim measureFaceBuilder1 As MeasureFaceBuilder measureFaceBuilder1 = workPart.MeasureManager.CreateMeasureFaceBuilder(Nothing) Dim unit1 As Unit = CType(workPart.UnitCollection.FindObject("SquareInch"), Unit) Dim unit2 As Unit = CType(workPart.UnitCollection.FindObject("Inch"), Unit) Dim objects1(0) As IParameterizedSurface Dim measureFaces1 As MeasureFaces Dim added1 As Boolean measureFaceBuilder1.FaceObjects.Clear() added1 = measureFaceBuilder1.FaceObjects.Add(inputFace) objects1(0) = inputFace measureFaces1 = workPart.MeasureManager.NewFaceProperties(unit1, unit2, 0.999, objects1) theFaceArea = measureFaces1.Area measureFaces1.Dispose() measureFaceBuilder1.FaceObjects.Clear() measureFaceBuilder1.Destroy() Return theFaceArea End Function End Modulewww.nxjournaling.com
RE: NXOpen.tag cannot be converted to NXOpen.Face