AnsweredAssumed Answered

strecth decal

Question asked by Евгений Кондратьев on Dec 2, 2015

Hi, all.

i make 2 decal (IDecal) for my model by example (2016 SOLIDWORKS API Help - Add Decal Example (C#) ).

First decal is normal and second decal is bad(very stretch).

           

it's my code:

void make_decal_for_face(Face2 face, string filename)

{

SelectionMgr swSelMgr = default(SelectionMgr);

ModelDocExtension swModelDocExt = default(ModelDocExtension);

Decal swDecal = default(Decal);

RenderMaterial swMaterial = default(RenderMaterial);

bool status = false;

int nDecalID = 0;           

 

 

//Create the decal

swModelDocExt = (ModelDocExtension)this.part.Extension;

swDecal = (Decal)swModelDocExt.CreateDecal();

swMaterial = (RenderMaterial)swDecal;

status = swMaterial.AddEntity(face);

swSelMgr = (SelectionMgr)this.part.SelectionManager;

this.part.ClearSelection2(true);

 

swMaterial.FileName = System.Environment.SpecialFolder.ProgramFiles + "SOLIDWORKS Corp\\SOLIDWORKS\\data\\graphics\\Decals\\Logos\\sw.p2d";

swMaterial.TextureFilename = filename;

swMaterial.MappingType = 0;

swMaterial.FixedAspectRatio = true;

swMaterial.FitHeight = true;

swMaterial.FitWidth = true;

status = swModelDocExt.AddDecal(swDecal, out nDecalID);

swModelDocExt.Rebuild((int)swRebuildOptions_e.swRebuildAll);

}

Result:

screen1.png

screen2.png

where error?

Outcomes