Hi I am trying to automate the ECE Radii check.For example I have to do a head impact study on car dashboard. The goal is where ever the head (generally a sphere of 165mm dia)touches the dashboard that face radius should be more than 3.5mm.
1. Now with the following code I am able to color the faces when it does not meet the radii requirement.In this code During radiinumber=1, I have some issues, I did create a work around which takes more time but runs just fine (Few faces when with body create radiinumber =1 but gives both u & v radius values, I have to create new face to measure the radius for these faces).
2. After Identify the red faces I have to do sphere check on the red faces, If they are not touched by sphere I don't have to worry about them. For this any ideas would be helpful. My thought is to run the sphere with touch constraints along all faces with collision detection on and highlight the faces which is not touched by sphere. But I wonder how much will be the running time when I run more than 100k faces.
Example: I have U-shaped part where the sphere is coming and touching from the top of U shape. Now I can ignore the bottom face of U which will never be touched by sphere since collision stopped the sphere in the top itself.
3. In catia the radius report shows the area in a face where it is lesser than the input (https://ww3.cad.de/foren/ubb/uploads/SmokieMcPot/F02.PNG), Is it any method we can do the same in NX also. where face have variable radius highlight only the area where the radii is lesser than the input value.
Option Strict Off Imports System Imports System.CollectionsImports System.Collections.GenericImports NXOpen Imports NXOpen.UFImports NXOpen.FeaturesImports NXOpen.UtilitiesImports NXOpen.Assemblies Module RadiiCheckTool Public theSession As Session = Session.GetSession()Public ufs As UFSession = UFSession.GetUFSession()Public theUISession As UI = UI.GetUIPublic lw As ListingWindow = theSession.ListingWindowDim workPart As NXOpen.Part= theSession.Parts.WorkDim displayPart As NXOpen.Part= theSession.Parts.DisplayDim theUI As UI = UI.GetUI Sub Main() Dim MyLayers As Layer.LayerManager= workPart.LayersDim RadiiNumber AsInteger=NothingDim RadiiValue(1)AsDoubleDim Positions(5)AsDoubleDim Params(3)AsDoubleDim i AsInteger=NothingDim j AsInteger=NothingDim aposition(2)AsDoubleDim junk3(2)AsDoubleDim junk2(1)AsDoubleDim junk1 AsDouble=NothingDim parm1(1)AsDoubleDim parm2(1)AsDoubleDim n1(2)AsDoubleDim n2(2)AsDoubleDim isparallel AsInteger=NothingDim MinRadii1 AsInteger=5Dim MinRadii2 AsInteger=3.5Dim Minradii3 AsInteger=3.5Dim firstleveltangentfaces As ArrayList =New ArrayList Dim secondleveltangentfaces As ArrayList =New ArrayList lw.Open()ForEach obj As DisplayableObject In theSession.Parts.Work.BodiesIf MyLayers.GetState(obj.Layer)<2ThenIf obj.IsBlanked=FalseThen' only check visible objectsIf obj.GetType.ToString="NXOpen.Body"Then' only check object types of bodyDim MyBody As Body =CType(obj, Body) 'Change the default color of the Body ApplyColorToSelectedItem(97, MyBody) Dim MyFaces()As Face = MyBody.GetFaces()'get all faces of the body For i =0To MyFaces.Length-1 Dim theedges()As Edge = MyFaces(i).GetEdgesDim InputEdgeCount AsInteger=Nothing InputEdgeCount = theedges.LengthDim ParallelCount AsInteger=0Dim theedgefaces(1)As Face Dim thesecondlevelfaces(1)As Face ForEach e1 As Edge In theedges theedgefaces = e1.GetFacesForEach f1 As Face In theedgefaces If f1.Tag<> MyFaces(i).TagThen' check a point on the common edge for tangancy ufs.Modl.AskCurveProps(e1.Tag, 0.5, aposition, junk3, junk3, junk3, junk1, junk1) ufs.Modl.AskFaceParm(MyFaces(i).Tag, aposition, parm1, aposition) ufs.Modl.AskFaceParm(f1.Tag, aposition, parm2, aposition) ufs.Modl.AskFaceProps(MyFaces(i).Tag, parm1, aposition, junk3, junk3, junk3, junk3, n1, junk2) ufs.Modl.AskFaceProps(f1.Tag, parm2, aposition, junk3, junk3, junk3, junk3, n2, junk2) ufs.Vec3.IsParallel(n1, n2, 0.01, isparallel)IfNot isparallel =1Then'Create edge curve and make it RedDim edgeArcTag As Tag ufs.Modl.CreateCurveFromEdge(e1.Tag, edgeArcTag)Dim MyCurve As TaggedObject = NXOpen.Utilities.NXObjectManager.Get(edgeArcTag) ApplyColorToSelectedItem(150, MyCurve) ChangeLineThickness(MyCurve)EndIfEndIfNextNext ParallelCount =0 ufs.Modl.AskFaceMinRadii(MyFaces(i).Tag, RadiiNumber, RadiiValue, Positions, Params) If RadiiValue(0)<0Then RadiiValue(0)= RadiiValue(0)*-1EndIfIf RadiiValue(1)<0Then RadiiValue(1)= RadiiValue(1)*-1EndIf RadiiValue(0)= Math.Round(RadiiValue(0), 1) RadiiValue(1)= Math.Round(RadiiValue(1), 1) If RadiiNumber =0Then'Planar Face ApplyColorToSelectedItem(108, MyFaces(i)) ElseIf RadiiNumber =1Then'One radius faceDim Radius1(1)AsDouble MeasureOffsetFace(MyFaces(i), Radius1) If Radius1(0)> MinRadii1 Or Radius1(1)> MinRadii1 Then ApplyColorToSelectedItem(108, MyFaces(i))ElseIf Radius1(0)> MinRadii2 And Radius1(0)< MinRadii1 Then ApplyColorToSelectedItem(78, MyFaces(i))ElseIf Radius1(1)> MinRadii2 And Radius1(1)< MinRadii1 Then ApplyColorToSelectedItem(78, MyFaces(i))ElseIf Radius1(0)> Minradii3 And Radius1(0)< MinRadii2 Then ApplyColorToSelectedItem(117, MyFaces(i))ElseIf Radius1(1)> Minradii3 And Radius1(1)< MinRadii2 Then ApplyColorToSelectedItem(117, MyFaces(i))Else ApplyColorToSelectedItem(150, MyFaces(i))EndIf ElseIf RadiiNumber =2Then'Two radius faceIf RadiiValue(0)> MinRadii1 And RadiiValue(1)> MinRadii1 Then ApplyColorToSelectedItem(108, MyFaces(i))ElseIf RadiiValue(0)> MinRadii2 And RadiiValue(1)> MinRadii2 And RadiiValue(0)< MinRadii1 And RadiiValue(1)< MinRadii1 Then ApplyColorToSelectedItem(78, MyFaces(i))ElseIf RadiiValue(0)> Minradii3 And RadiiValue(1)> Minradii3 And RadiiValue(0)< MinRadii2 And RadiiValue(1)< MinRadii2 Then ApplyColorToSelectedItem(117, MyFaces(i))Else ApplyColorToSelectedItem(150, MyFaces(i))EndIf EndIf NextFace: NextEndIfEndIfEndIfNext EndSub PublicSub ApplyColorToSelectedItem(ByRef ColorInput AsInteger, ByRef RefObj As NXObject) Dim DispModify As DisplayModification =NothingDim ColObj(0)As DisplayableObject Dim markId1 As NXOpen.Session.UndoMarkId=Nothing markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Edit Object Display") DispModify = theSession.DisplayManager.NewDisplayModification() DispModify.ApplyToAllFaces=True DispModify.ApplyToOwningParts=False DispModify.NewColor= ColorInput DispModify.NewWidth= NXOpen.DisplayableObject.ObjectWidth.One ColObj(0)= RefObj DispModify.Apply(ColObj)Dim nErrs2 AsInteger=Nothing nErrs2 = theSession.UpdateManager.DoUpdate(markId1) ColObj(0)=Nothing DispModify.Dispose() EndSub PublicSub ChangeLineThickness(ByRef RefObj As NXObject)Dim DispModify As DisplayModification =NothingDim ColObj(0)As DisplayableObject Dim markId1 As NXOpen.Session.UndoMarkId=Nothing markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Edit Object Display") DispModify = theSession.DisplayManager.NewDisplayModification() DispModify.ApplyToAllFaces=True DispModify.ApplyToOwningParts=False DispModify.NewWidth= NXOpen.DisplayableObject.ObjectWidth.Nine DispModify.NewWidth= NXOpen.DisplayableObject.ObjectWidth.Thick ColObj(0)= RefObj DispModify.Apply(ColObj)Dim nErrs2 AsInteger=Nothing nErrs2 = theSession.UpdateManager.DoUpdate(markId1) ColObj(0)=Nothing DispModify.Dispose()EndSub PublicFunction MeasureOffsetFace(ByRef MyFace As Face, ByVal Radius1()AsDouble)Dim RadiiNumber AsInteger=NothingDim RadiiValue(1)AsDoubleDim Positions(5)AsDoubleDim Params(3)AsDoubleDim MyFeature As NXOpen.Features.Feature=NothingDim offsetSurfaceBuilder1 As NXOpen.Features.OffsetSurfaceBuilder=Nothing offsetSurfaceBuilder1 = workPart.Features.CreateOffsetSurfaceBuilder(MyFeature) offsetSurfaceBuilder1.Tolerance=0.01Dim scCollector1 As NXOpen.ScCollector=Nothing scCollector1 = workPart.ScCollectors.CreateCollector()Dim faces1(0)As NXOpen.FaceDim face1 As NXOpen.Face= MyFace faces1(0)= face1 Dim faceDumbRule1 As NXOpen.FaceDumbRule=Nothing faceDumbRule1 = workPart.ScRuleFactory.CreateRuleFaceDumb(faces1)Dim rules1(0)As NXOpen.SelectionIntentRule rules1(0)= faceDumbRule1 scCollector1.ReplaceRules(rules1, False)Dim faceSetOffset1 As NXOpen.GeometricUtilities.FaceSetOffset=Nothing faceSetOffset1 = workPart.FaceSetOffsets.CreateFaceSet("0", scCollector1, False, 0) offsetSurfaceBuilder1.FaceSets.Append(faceSetOffset1)Dim nXObject1 As NXOpen.NXObject=Nothing nXObject1 = offsetSurfaceBuilder1.Commit() offsetSurfaceBuilder1.Destroy() Dim MyF As OffsetSurface = NXOpen.Utilities.NXObjectManager.Get(nXObject1.Tag)Dim NewFacesList()As Face = MyF.GetFaces() ufs.Modl.AskFaceMinRadii(NewFacesList(0).Tag, RadiiNumber, RadiiValue, Positions, Params)If RadiiValue(0)<0Then RadiiValue(0)= RadiiValue(0)*-1EndIfIf RadiiValue(1)<0Then RadiiValue(1)= RadiiValue(1)*-1EndIf Radius1(0)= Math.Round(RadiiValue(0), 1) Radius1(1)= Math.Round(RadiiValue(1), 1)Dim markId1 As NXOpen.Session.UndoMarkId=Nothing markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Delete") theSession.UpdateManager.ClearErrorList()Dim objects1(0)As NXOpen.NXObject objects1(0)= MyF Dim nErrs1 AsInteger=Nothing nErrs1 = theSession.UpdateManager.AddToDeleteList(objects1)Dim nErrs2 AsInteger=Nothing nErrs2 = theSession.UpdateManager.DoUpdate(markId1) theSession.DeleteUndoMark(markId1, Nothing) Return Radius1(1) EndFunction PublicFunction GetUnloadOption(ByVal dummy AsString)AsInteger'Unloads the image immediately after execution within NX GetUnloadOption = NXOpen.Session.LibraryUnloadOption.ImmediatelyEndFunction EndModule