1 Reply Latest reply on Mar 17, 2016 5:10 PM by Artem Taturevych

    Why is it sometimes impossible to set IBody2::MaterialPropertyValues2

    Brad Phelan

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


              public double[] Materials




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

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

                          return InitMat();



                          return castArray;





                      var materialPropertyValues2 = value ?? InitMat();

                      _Body.MaterialPropertyValues2 = materialPropertyValues2;





      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);


                  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.