YviKyvi
Mechanical
- Feb 3, 2020
- 12
Hey,
I try to create a plane on a face in an assembly. I know I have to wavelink the component of the face, but I can't figure out how it works.
I have to replace these FindObject lines from the recorded journal:
I already found this thread: but I can't work with the LINKED_FACE(0), because I want to choose any of the faces.
I am using blockstyler for the selection with the selectObject method.
My Code is not working like I want it to, because it's using only the position of the face in the linked body but not the position of the face in the assembly.
That's my little changed recorded journal:
Any help is highly appreciated!
Thanks,
Yvonne
I try to create a plane on a face in an assembly. I know I have to wavelink the component of the face, but I can't figure out how it works.
I have to replace these FindObject lines from the recorded journal:
Code:
Dim face1 As NXOpen.Face = CType(component1.FindObject("PROTO#.Features|CYLINDER(1)|FACE 1 {(0,0,172) CYLINDER(1)}"), NXOpen.Face)
...
Dim face2 As NXOpen.Face = CType(extractFace2.FindObject("FACE 1 {(85.2937910603973,125.9999999999999,-0) LINKED_FACE(8)}"), NXOpen.Face)
I already found this thread: but I can't work with the LINKED_FACE(0), because I want to choose any of the faces.
I am using blockstyler for the selection with the selectObject method.
My Code is not working like I want it to, because it's using only the position of the face in the linked body but not the position of the face in the assembly.
That's my little changed recorded journal:
Code:
Public Function makePlane()
Dim displayPart As NXOpen.Part = theSession.Parts.Display
Dim nullNXOpen_Features_Feature As NXOpen.Features.Feature = Nothing
Dim datumPlaneBuilder1 As NXOpen.Features.DatumPlaneBuilder = Nothing
datumPlaneBuilder1 = workPart.Features.CreateDatumPlaneBuilder(nullNXOpen_Features_Feature)
Dim plane1 As NXOpen.Plane = Nothing
plane1 = datumPlaneBuilder1.GetPlane()
Dim unit1 As NXOpen.Unit = CType(workPart.UnitCollection.FindObject("MilliMeter"), NXOpen.Unit)
Dim expression1 As NXOpen.Expression = Nothing
expression1 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim expression2 As NXOpen.Expression = Nothing
expression2 = workPart.Expressions.CreateSystemExpressionWithUnits("0", unit1)
Dim coordinates1 As NXOpen.Point3d = New NXOpen.Point3d(0.0, 0.0, 0.0)
Dim point1 As NXOpen.Point = Nothing
point1 = workPart.Points.CreatePoint(coordinates1)
plane1.SetUpdateOption(NXOpen.SmartObject.UpdateOption.WithinModeling)
Dim extractFaceBuilder1 As NXOpen.Features.ExtractFaceBuilder = Nothing
extractFaceBuilder1 = workPart.Features.CreateExtractFaceBuilder(nullNXOpen_Features_Feature)
extractFaceBuilder1.Type = NXOpen.Features.ExtractFaceBuilder.ExtractType.Face
extractFaceBuilder1.ParentPart = NXOpen.Features.ExtractFaceBuilder.ParentPartType.OtherPart
extractFaceBuilder1.Associative = True
Dim selectDisplayableObjectList1 As NXOpen.SelectDisplayableObjectList = Nothing
selectDisplayableObjectList1 = extractFaceBuilder1.ObjectToExtract
Dim tagObj As NXOpen.TaggedObject() = selection0.GetSelectedObjects
Dim face1 As NXOpen.Face = CType(tagObj(0), NXOpen.Face)
Dim added1 As Boolean = Nothing
added1 = selectDisplayableObjectList1.Add(face1)
Dim feature1 As NXOpen.Features.Feature = Nothing
feature1 = extractFaceBuilder1.CommitCreateOnTheFly()
Dim waveLinkRepository1 As NXOpen.GeometricUtilities.WaveLinkRepository = Nothing
waveLinkRepository1 = workPart.CreateWavelinkRepository()
waveLinkRepository1.SetNonFeatureApplication(False)
waveLinkRepository1.SetBuilder(datumPlaneBuilder1)
Dim extractFace1 As NXOpen.Features.ExtractFace = CType(feature1, NXOpen.Features.ExtractFace)
waveLinkRepository1.SetLink(extractFace1)
Dim extractFaceBuilder2 As NXOpen.Features.ExtractFaceBuilder = Nothing
extractFaceBuilder2 = workPart.Features.CreateExtractFaceBuilder(extractFace1)
extractFaceBuilder2.Associative = False
Dim feature2 As NXOpen.Features.Feature = Nothing
feature2 = extractFaceBuilder2.CommitCreateOnTheFly()
extractFaceBuilder2.Destroy()
Dim extractFace2 As NXOpen.Features.ExtractFace = CType(feature2, NXOpen.Features.ExtractFace)
extractFace2.SetName("Fläche")
extractFaceBuilder1.Destroy()
plane1.SetMethod(NXOpen.PlaneTypes.MethodType.Distance)
Dim geom1(0) As NXOpen.NXObject
Dim face2 As NXOpen.Face = face1
geom1(0) = face2
plane1.SetGeometry(geom1)
plane1.SetFlip(False)
plane1.SetReverseSide(False)
Dim expression3 As NXOpen.Expression = Nothing
expression3 = plane1.Expression
expression3.RightHandSide = CType(integer0.Value, String)
plane1.SetAlternate(NXOpen.PlaneTypes.AlternateType.One)
plane1.Evaluate()
plane1.RemoveOffsetData()
plane1.Evaluate()
datumPlaneBuilder1.ResizeDuringUpdate = True
Dim feature3 As NXOpen.Features.Feature = Nothing
feature3 = datumPlaneBuilder1.CommitFeature()
Dim datumPlaneFeature1 As NXOpen.Features.DatumPlaneFeature = CType(feature3, NXOpen.Features.DatumPlaneFeature)
Dim datumPlane1 As NXOpen.DatumPlane = Nothing
datumPlane1 = datumPlaneFeature1.DatumPlane
datumPlane1.SetReverseSection(False)
datumPlaneBuilder1.Destroy()
waveLinkRepository1.Destroy()
End Function
Any help is highly appreciated!
Thanks,
Yvonne