AnsweredAssumed Answered

Positioning of decals added to a face

Question asked by Colin Poushay on Jun 8, 2016
Latest reply on Jun 9, 2016 by Colin Poushay

I've been working on a macro/add-in that adds a decal to a selected face, but haven't been able to accurately place it in the location I want. It seems that when you add a decal to a face, it is placed directly on the center of the face. I want to change its placement, so that is centred over the selection point (the point on the face selected, gotten from the selection manager).

 

Here is what the code looks like:

 

           //set up render material, 1" x 2"

           RenderMaterial renderMaterial = (RenderMaterial)decal;

            renderMaterial.MappingType = 0;

            renderMaterial.Height = 1 * Constants.metersPerInch;

            renderMaterial Width = 2 * Constants.metersPerInch;

 

             //face properties

            double[] sectProps = swModelDocExt.GetSectionProperties2(f);

            //face center

            double[] faceCenter = new double[] { sectProps[2], sectProps[3], sectProps[4] };

 

            // get the vector from face center to selection point

            double[] translationVector = VecMath.subtract(selectionPoint, faceCenter);

         

            //set position details

            //swMaterial.XPosition = ???;

            //swMaterial.YPosition = ???;

         

I think all that is left is to convert translationVector from model basis to another basis, but I am not sure which one that is.

Outcomes