.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

change thumbnail shape (canvas) of Material

0 REPLIES 0
Reply
Message 1 of 1
pvhuyg
96 Views, 0 Replies

change thumbnail shape (canvas) of Material

pvhuyg_0-1665051709829.png


I am creating materials.  When I create it, the thumbnail is always Object.  I want to convert to canvas ?

 

ObjectId materialId = ObjectId.Null;
Document doc = Application.DocumentManager.MdiActiveDocument;
using (Transaction acTrans = doc.TransactionManager.StartTransaction())
{
// Get the material library
DBDictionary matLib = acTrans.GetObject(doc.Database.MaterialDictionaryId, OpenMode.ForRead) as DBDictionary;

// If this material does not exist

if (matLib.Contains(sMaterialName) == false)
{
// Create the texture map image
ImageFileTexture tex = new ImageFileTexture();
tex.SourceFileName = sTextureMapPath;
double uScale = 1.0/width, vScale = 1.0 / height;
//double uOffset = 2, vOffset = 2;
Matrix3d mx = new Matrix3d(new double[]{
uScale, 0, 0, uScale * uOffset,
0, vScale, 0, vScale * vOffset,
0, 0, 2, 0,
0, 0, 0, 2 });


// We need a cylindrical mapping with no tiling
Mapper mapper = new Mapper(Projection.InheritProjection, Tiling.Tile, Tiling.Tile, AutoTransform.None, mx);

MaterialMap map = new MaterialMap(Source.Scene, tex, 1.0, mapper);

// Set the opacity and refraction maps
MaterialDiffuseComponent mdc = new MaterialDiffuseComponent(new MaterialColor(Method.Override,1,new Autodesk.AutoCAD.Colors.EntityColor(80,80,80)), map);
MaterialRefractionComponent mrc = new MaterialRefractionComponent(1.52, map);


// Create a new material

Material mat = new Material();
mat.Name = sMaterialName;
mat.Diffuse = mdc;
mat.Refraction = mrc;
mat.Mode = Mode.Realistic;
mat.Reflectivity = 1.0;
mat.IlluminationModel = IlluminationModel.BlinnShader;

// Add it to the library
matLib.UpgradeOpen();
materialId = matLib.SetAt(sMaterialName, mat);
acTrans.AddNewlyCreatedDBObject(mat, true);
acTrans.Commit();
}
}
0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report