What is a good way to tell (in code) whether to reverse the normal when re-connecting a broken wave linked surface? I am programmatically instantiating a template model into an assembly and I need the new wave linked face normal to match the template model's.
I tried measuring the angle between the old and the new faces but I can't seem to get that to work.
here's what I have:
//get the existing (broken) wave link feature
NXOpen.Features.ExtractFace topSurfaceFeature = (NXOpen.Features.ExtractFace)Utilities.GetNamedFeature(workPart, "TopSkinSurface");
workPart.Features.SetEditWithRollbackFeature(topSurfaceFeature);
theSession.UpdateManager.InterpartDelay = true;
topSurfaceFeature.MakeCurrentFeature();
NXOpen.Features.ExtractFaceBuilder extractFaceBuilder1;
extractFaceBuilder1 = workPart.Features.CreateExtractFaceBuilder(topSurfaceFeature);
Face oldface = topSurfaceFeature.GetFaces().First();
//NXOpen.Features.Swept swept1 = (NXOpen.Features.Swept)displayPart.Features.FindObject("SWEPT(11)");
//Face face1 = (Face)swept1.FindObject("FACE 10001 {(57.2240163032518,103.7084239064676,0.2605955534797) SWEPT(11)}");
Face face1 = (Face)face_select01.GetSelectedObjects().First();
Unit nullUnit = null;
MeasureAngle ang = workPart.MeasureManager.NewAngle(nullUnit, oldface, NXOpen.MeasureManager.EndpointType.StartPoint, face1, NXOpen.MeasureManager.EndpointType.StartPoint,true, false);
if (ang.Value > 90)
{
extractFaceBuilder1.FaceReverseDirection = true;
extractFaceBuilder1.RecreateVectorOfHelpDirVector();
extractFaceBuilder1.FlipFaceChainDirectionSense(face1);
}
DisplayableObject[] replacementobjects1 = new DisplayableObject[0];
extractFaceBuilder1.ReplacementAssistant.SetNewParents(replacementobjects1);
SelectionIntentRule[] rules1 = new SelectionIntentRule[0];
extractFaceBuilder1.FaceChain.ReplaceRules(rules1, false);
extractFaceBuilder1.FixAtCurrentTimestamp = true;
DisplayableObject[] replacementobjects2 = new DisplayableObject[1];
NXOpen.Features.Feature faceFeature = displayPart.Features.GetAssociatedFeature(face1);
replacementobjects2[0] = face1;
extractFaceBuilder1.ReplacementAssistant.SetNewParents(replacementobjects2);
Face[] boundaryFaces1 = new Face[0];
FaceTangentRule faceTangentRule1;
faceTangentRule1 = workPart.ScRuleFactory.CreateRuleFaceTangent(face1, boundaryFaces1, 0.5);
SelectionIntentRule[] rules2 = new SelectionIntentRule[1];
rules2[0] = faceTangentRule1;
extractFaceBuilder1.FaceChain.ReplaceRules(rules2, false);
extractFaceBuilder1.FrecAtTimeStamp = faceFeature;
extractFaceBuilder1.Associative = true;
NXObject nXObject2;
nXObject2 = extractFaceBuilder1.Commit();
extractFaceBuilder1.Destroy();
The error I'm getting is on line 14 and says the third parameter is invalid (I've tried all three options for the endpoint type though).
Error Solved
I realized that the MeasureManager.NewAngle function requires both objects to be in the workPart. I solved this by measuring the angle of the new surface to a common datum before starting to re-link the feature and comparing that to the angle between the old surface and the same datum.