ds-blue-logo
Preview  |  SOLIDWORKS USER FORUM
Use your SOLIDWORKS ID or 3DEXPERIENCE ID to log in.
VVVadim Vadim22/09/2015

Hello, guys. I'm working with SolidWorks plug-in. I need to create transparent body, but I can't do it. Can someone help me ??
I create new body by IModeler class, like this:

        protected virtual IBody2[] OnCreateBodies(ISldWokrs application, IModelDoc2 document, DetectorMacroFeatureData properties)

        {

            double halfWidthX = (double)properties["X Half Width"].Value;

            double halfWidthY = (double)properties["Y Half Width"].Value;

            IModeler modeler = application.IGetModeler();

            IPartDoc part = document as IPartDoc;

            Point3D[] points = new Point3D[] { new Point3D(-halfWidthX, -halfWidthY, 0.5), new Point3D(-halfWidthX, halfWidthY, 0.5),

                                               new Point3D(halfWidthX, halfWidthY, 0.5), new Point3D(halfWidthX, -halfWidthY, 0.5) };

            Curve[] border = new Curve[4];

            for (int i = 0; i < 4; i++)

            {

                border[i] = SWGeometry.CreateLine(application, points[i], points[(i + 1) % 4]);

            }

            Surface planeSurf = modeler.CreatePlanarSurface2(new double[] { 0, 0, 0.5 }, new double[] { 0, 0, 1 }, new double[] { 1, 0, 0 }) as Surface;

            IBody2 detectorBody = planeSurf.CreateTrimmedSheet4(border, true) as IBody2;        

            return new IBody2[] { detectorBody };

        }

When i use this function, i create correct planar body. Now i need to do it invisible (not hiden). So i want to set transparent as 100 %.
I reed, that i can do it by using MaterialPropertyValues2 property. But it is not work for me. When i try to get or set it, it always equals NULL.

var material = detectorBody.MaterialPropertyValues2 as double[]; // return NULL, like double[] or like object, anyway it equals NULL

material[7] = 1.0;

detectorBody.MaterialPropertyValues2 = material; // still equals NULL

Can someone help me or show some offers ?? I'm begginer in work with SolidWorks API, so it will be nice, if you show me some examples.