Posts: 15
Registered: ‎12-21-2010
Message 1 of 2 (113 Views)

Material from image file with parameters (including rotation)

113 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
Posts: 576
Registered: ‎06-02-2009
Message 2 of 2 (66 Views)

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

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community