<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Material from image file with parameters (including rotation) in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/material-from-image-file-with-parameters-including-rotation/m-p/4416221#M47848</link>
    <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Did you try setting the mapper matrix to a rotation? In the example it is just set to a scale.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;[CommandMethod("MaterialInfo")]
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)
        return;

    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...
    }
}&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Philippe.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 10 Sep 2013 21:30:38 GMT</pubDate>
    <dc:creator>philippe.leefsma</dc:creator>
    <dc:date>2013-09-10T21:30:38Z</dc:date>
    <item>
      <title>Material from image file with parameters (including rotation)</title>
      <link>https://forums.autodesk.com/t5/net-forum/material-from-image-file-with-parameters-including-rotation/m-p/4401441#M47847</link>
      <description>&lt;P&gt;Has anyone an example code of creating material from image file including the setting of parameters like seen in the materials dialog.&amp;nbsp; I need to set the rotation angle along with the U/V tile and U/V offsets at the same time.&amp;nbsp; This example shows part but does not do rotation.&lt;BR /&gt;&lt;BR /&gt;&lt;A target="_blank" href="http://adndevblog.typepad.com/autocad/2012/05/setting-u-and-v-tile-scale-of-a-newly-created-material-using-net.html"&gt;http://adndevblog.typepad.com/autocad/2012/05/setting-u-and-v-tile-scale-of-a-newly-created-material-using-net.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to make the image fit a rotated face that is usually of the same proportions as the image.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Sep 2013 17:41:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/material-from-image-file-with-parameters-including-rotation/m-p/4401441#M47847</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-09-05T17:41:26Z</dc:date>
    </item>
    <item>
      <title>Re: Material from image file with parameters (including rotation)</title>
      <link>https://forums.autodesk.com/t5/net-forum/material-from-image-file-with-parameters-including-rotation/m-p/4416221#M47848</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Did you try setting the mapper matrix to a rotation? In the example it is just set to a scale.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;[CommandMethod("MaterialInfo")]
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)
        return;

    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...
    }
}&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Philippe.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Sep 2013 21:30:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/material-from-image-file-with-parameters-including-rotation/m-p/4416221#M47848</guid>
      <dc:creator>philippe.leefsma</dc:creator>
      <dc:date>2013-09-10T21:30:38Z</dc:date>
    </item>
  </channel>
</rss>

