15 Posts
1 Kudo
Registered: ‎12-21-2010
Post 1 of 2

Material from image file with parameters (including rotation)

119 Views, 1 Replies
09-05-2013 10:33 AM

Has anyone an example code of creating material from image file including the setting of parameters like seen in the materials dialog.  I need to set the rotation angle along with the U/V tile and U/V offsets at the same time.  This example shows part but does not do rotation.



I am trying to make the image fit a rotated face that is usually of the same proportions as the image.

ADN Support Specialist
687 Posts
80 Kudos
Registered: ‎06-02-2009
Post 2 of 2

Re: Material from image file with parameters (including rotation)

09-10-2013 02:30 PM in reply to: User48



Did you try setting the mapper matrix to a rotation? In the example it is just set to a scale.


Alternatively you could try retrieving an existing texture info that is already rotated and check how its matrix looks like. Here is some incomplete code that illustrates how to access the texture properties:


public void MaterialInfo()
    Document doc = Application.DocumentManager.MdiActiveDocument;
    Database db = doc.Database;
    Editor ed = doc.Editor;

    PromptEntityOptions peo = new PromptEntityOptions(
        "\nSelect a 3D solid: ");

    peo.SetRejectMessage("\nInvalid selection...");
    peo.AddAllowedClass(typeof(Solid3d), true);

    PromptEntityResult per = ed.GetEntity(peo);

    if (per.Status != PromptStatus.OK)

    using (Transaction Tx = db.TransactionManager.StartTransaction())
        Solid3d solid = Tx.GetObject(per.ObjectId, OpenMode.ForRead)
            as Solid3d;

        Material material = Tx.GetObject(solid.MaterialId, OpenMode.ForRead)
            as Material;

        MaterialMap map = material.Bump;

        if(map.Texture is ImageFileTexture)
            ImageFileTexture imgTex = map.Texture as ImageFileTexture;

            ed.WriteMessage("\nSource file: " + imgTex.SourceFileName);

        Mapper mapper = map.Mapper;

        //mapper.Transform is matrix3d...





Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!