Forums:
Hey NXOpen Users ;)
I desperately tried to link created expressions with linear dimensions, but I just don´t get it. It would be really awesome if someone could tell me how this works :)
Below you can find a C# Code Snippet of my Journal. Initially the Journal creates a sketch (containing only a line). Then it creates a number expression and adds a linear dimension to the line. If I run my journal, I get an error,saying that the object referene is not set on an object instance..
// Get the unit NXOpen.Unit mm =(Unit)thePart.UnitCollection.FindObject("MilliMeter");//Create the Expression NXOpen.Expression expression1; expression1 = thePart.Expressions.CreateNumberExpression("Length = 200", mm); // Create the linear dimension NXOpen.Annotations.Dimension nuller =null; SketchLinearDimensionBuilder linDimension1; linDimension1 = thePart.Sketches.CreateLinearDimensionBuilder(nuller); // Connect the linear dimension to the geometry of the sketch linDimension1.FirstAssociativity.SetValue(InferSnapType.SnapType.Start, lino, thePart.ModelingViews.WorkView, sp, null, null, origin); linDimension1.SecondAssociativity.SetValue(InferSnapType.SnapType.End, lino, thePart.ModelingViews.WorkView, ep, null, null, origin); //Connect the linear dimension with the expression linDimension1.Driving.ExpressionValue.SetFormula("Length"); linDimension1.Driving.ExpressionMode= NXOpen.Annotations.DrivingValueBuilder.DrivingExpressionMode.KeepExpression;