cucuu
New member
- Mar 9, 2015
- 14
Hello,
I am writing a journal to create an airfoil geometry which set by expressions. The journal will be used 1 time to set the geometries and expressions, after that the geometry changes will be made only by the expressions.
My question is, is there a way to define an associative vector expression to an associative datum axis created at an associative percentage of a spline.
For example i have a camberline (studiospline), at 50% of that curve i created a datumaxis normal to the curve. I want to create an associative vector expression that defines that datumaxis. When the inputs are changed, the camberspline will change thus, the datumaxis will change. I want the vector expression also change.
I will explain a method i tried. I created an associative angle measurement between the datum axis and the X-axis, so i have an angle. Then i created a Vector expression "Vector(cos(angle),sin(angle),0)". But the measurement name is automatic (ie. p2) and i can't define this name in journal. I want the journal to create an expression "Vector(cos(p2),sin(p2),0)" if the measurement name is defined as p2 automatically. I setname to measurement, i tried the journalidentifier and the tag but i can't manage to do what i want.
Any help will be appreciated.
Codes are given below.
Function that creates datumaxis
Function that creates the measurement
Main code
The section below creates the measurement. Now i want the journal to create an expression of a vector "Vector(cos(p2),sin(p2),0)" if the measurement name in expression tab is p2.
I am writing a journal to create an airfoil geometry which set by expressions. The journal will be used 1 time to set the geometries and expressions, after that the geometry changes will be made only by the expressions.
My question is, is there a way to define an associative vector expression to an associative datum axis created at an associative percentage of a spline.
For example i have a camberline (studiospline), at 50% of that curve i created a datumaxis normal to the curve. I want to create an associative vector expression that defines that datumaxis. When the inputs are changed, the camberspline will change thus, the datumaxis will change. I want the vector expression also change.
I will explain a method i tried. I created an associative angle measurement between the datum axis and the X-axis, so i have an angle. Then i created a Vector expression "Vector(cos(angle),sin(angle),0)". But the measurement name is automatic (ie. p2) and i can't define this name in journal. I want the journal to create an expression "Vector(cos(p2),sin(p2),0)" if the measurement name is defined as p2 automatically. I setname to measurement, i tried the journalidentifier and the tag but i can't manage to do what i want.
Any help will be appreciated.
Codes are given below.
Function that creates datumaxis
Code:
public static DatumAxis CreateDatumAxis(Part thePart, NXOpen.Features.StudioSpline spline, double spline_percent, string name)
{
NXOpen.Features.Feature nullFeatures_Feature = null;
NXOpen.Features.StudioSpline studioSpline1 = spline;
Spline spline1 = (Spline)studioSpline1.FindObject("CURVE 1");
NXOpen.Features.DatumAxisBuilder datumAxisBuilder1;
datumAxisBuilder1 = thePart.Features.CreateDatumAxisBuilder(nullFeatures_Feature);
datumAxisBuilder1.Type = NXOpen.Features.DatumAxisBuilder.Types.OnCurveVector;
datumAxisBuilder1.ArcLength.IsPercentUsed = true;
datumAxisBuilder1.CurveOrientation = NXOpen.Features.DatumAxisBuilder.CurveOrientations.Normal;
datumAxisBuilder1.IsAssociative = true;
datumAxisBuilder1.Curve.Value = spline1;
datumAxisBuilder1.ArcLength.Path.Value = spline1;
datumAxisBuilder1.ArcLength.Update(NXOpen.GeometricUtilities.OnPathDimensionBuilder.UpdateReason.Path);
datumAxisBuilder1.ArcLength.Expression.Value = spline_percent;
datumAxisBuilder1.IsAxisReversed = true;
NXObject nXObject1;
nXObject1 = datumAxisBuilder1.Commit();
nXObject1.SetName(name);
datumAxisBuilder1.Destroy();
NXOpen.Features.DatumAxisFeature a = (NXOpen.Features.DatumAxisFeature)nXObject1;
return a.DatumAxis;
}
Function that creates the measurement
Code:
public static Measure CreateNormalVectorAngleMeasurement(Part thePart, DatumAxis axis1, DatumAxis axis2, string name)
{
NXObject nullNXObject = null;
MeasureAngleBuilder measureAngleBuilder1;
measureAngleBuilder1 = thePart.MeasureManager.CreateMeasureAngleBuilder(nullNXObject);
measureAngleBuilder1.Object1.Value = axis1;
measureAngleBuilder1.Object2.Value = axis2;
Unit nullUnit = null;
MeasureAngle measureAngle1;
measureAngle1 = thePart.MeasureManager.NewAngle(nullUnit, axis1, NXOpen.MeasureManager.EndpointType.StartPoint, axis2, NXOpen.MeasureManager.EndpointType.StartPoint, true, false);
Measure measure1;
measure1 = measureAngle1.CreateFeature();
measureAngle1.Dispose();
measure1.SetName(name);
measureAngleBuilder1.Destroy();
return measure1;
}
Main code
Code:
public static void Main(string[] args)
{
Session theSession = Session.GetSession();
Part workPart = theSession.Parts.Work;
Part displayPart = theSession.Parts.Display;
CamberClass Camber = new CamberClass(workPart, theSession);
#region Camber Inputs and Expression
Camber.B1m = 19.0;
Camber.B2m = -65;
Camber.Cax = 14.115;
Camber.Stagger = -38.45;
Camber.grc = 1;
Camber.degree = 3;
Functions.CreateExpression(workPart, "B1m", Camber.B1m.ToString(CultureInfo.InvariantCulture), "Number");
Functions.CreateExpression(workPart, "B2m", Camber.B2m.ToString(CultureInfo.InvariantCulture), "Number");
Functions.CreateExpression(workPart, "Cax", Camber.Cax.ToString(CultureInfo.InvariantCulture), "Number");
Functions.CreateExpression(workPart, "Stagger", Camber.Stagger.ToString(CultureInfo.InvariantCulture), "Number");
Functions.CreateExpression(workPart, "Camber_grc", Camber.grc.ToString(CultureInfo.InvariantCulture), "Number");
Functions.CreateExpression(workPart, "Camberdegree", Camber.degree.ToString(CultureInfo.InvariantCulture), "Number");
//degree>3 input Cys
if (Camber.degree > 3)
{
Camber.Cy.Add(3); //y coordinate of control points except P0,P1,Pn-1 [P2=Cy(0)...Pn-2=Cy(degree-4)]
Camber.Cy.Add(-5); //Degree-4 //e kadar gir, girilmezse 0 alır
for (int i = 2; i <= Camber.degree - 2; i++)
{
Functions.CreateExpression(workPart, "Camber_Cy" + i.ToString(), Camber.Cy[i - 2].ToString(CultureInfo.InvariantCulture), "Number");
}
}
#endregion
Point3d StartPoint = new Point3d(0, 0, 0);
NXOpen.Features.DatumCsys ABSCSYS;
ABSCSYS = Functions.CreateAbsoluteCoordinateSystem(workPart, "Absolute Coordinate System");
Camber.CamberControlPointsExpressions(StartPoint, "Camber");
DatumAxis x1;
x1 = Functions.CreateDatumAxis(workPart, Camber.CamberSpline, 50, "datum1");
DatumAxis x2;
x2 = (DatumAxis)workPart.Datums.FindObject(ABSCSYS.JournalIdentifier.ToString() + " X axis");
Measure a;
a = Functions.CreateNormalVectorAngleMeasurement(workPart, x1, x2, "a1");
}
The section below creates the measurement. Now i want the journal to create an expression of a vector "Vector(cos(p2),sin(p2),0)" if the measurement name in expression tab is p2.
Code:
DatumAxis x1;
x1 = Functions.CreateDatumAxis(workPart, Camber.CamberSpline, 50, "datum1");
DatumAxis x2;
x2 = (DatumAxis)workPart.Datums.FindObject(ABSCSYS.JournalIdentifier.ToString() + " X axis");
Measure a;
a = Functions.CreateNormalVectorAngleMeasurement(workPart, x1, x2, "a1");