AnsweredAssumed Answered

Why is it sometimes impossible to set IBody2::MaterialPropertyValues2

Question asked by Brad Phelan on Mar 17, 2016
Latest reply on Mar 17, 2016 by Artem Taturevych

I have a method for setting and getting the materials on a body.

 

        public double[] Materials

        {

            get

            {

                var castArray = _Body.MaterialPropertyValues2.CastArray<double>();

                if(castArray == null || castArray.Length == 0)

                    return InitMat();

                else

                {

                    return castArray;

                }

            }

            set

            {

                var materialPropertyValues2 = value ?? InitMat();

                _Body.MaterialPropertyValues2 = materialPropertyValues2;

                Debug.Assert(_Body.MaterialPropertyValues2!=null);

            }

        }

 

Note the assert that the materials should not be null after set. For some objects it always is null. For example a body I create like

 

        public Body2 CreateTool(double radius, double length, double x,double y,double z, double c)

        {

            var modeler = (IModeler)SwApp.GetModeler();

            var facePos = new double[] {x, y, z};

            var direction = new double[] {1, 0, 0};

 

 

            var array = facePos.Concat(direction).Concat(new[] {radius, length}).ToArray();

            var body = (Body2)modeler.CreateBodyFromCyl(array);

                var transform = (MathTransform) MathUtility.CreateTransformRotateAxis(Mp(0, 0, 0), ZAxis, c);

            body.ApplyTransform(transform);

            return body;

        }

 

will not allow me to set it's material. This may be the source of the problem from my previous question about tessellation not working. If there is no material then maybe no tessellation will occur.

Outcomes