<?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: DirectShape with GeometryInstance and non conformal Transform in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/directshape-with-geometryinstance-and-non-conformal-transform/m-p/13135647#M2208</link>
    <description>&lt;P&gt;Thanks. But this doesn't work. The variable geoInst is already an IList&amp;lt;GeometryObject&amp;gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Above code with a "Box" is only a simplified example. Real structure is more complex.&lt;/P&gt;&lt;P&gt;"Box" is just an identifier to refer to a registered geometry or DirectShapeType within the Library.&lt;/P&gt;&lt;P&gt;DirectShapeLibrary enables me to crate DirectShapes with Instances referencing the Geometry of a DirectShapeType.&lt;/P&gt;&lt;P&gt;So I have many Instances with different Transforms for one Geometry. It is the same structure my external data format has. The Geometry Instance has a Transform property which an AddIn can read back.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works fine. But Instances with non conformal Transform (e.g. non uniform scale) are not selectable in the UI.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers, Tom&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 07 Nov 2024 08:02:31 GMT</pubDate>
    <dc:creator>thomas.hain</dc:creator>
    <dc:date>2024-11-07T08:02:31Z</dc:date>
    <item>
      <title>DirectShape with GeometryInstance and non conformal Transform</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/directshape-with-geometryinstance-and-non-conformal-transform/m-p/13133340#M2206</link>
      <description>&lt;P&gt;This question relates to this one&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/revit-api-forum/access-transform-of-a-directshape/m-p/13100704#M82239" target="_blank"&gt;https://forums.autodesk.com/t5/revit-api-forum/access-transform-of-a-directshape/m-p/13100704#M82239&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've created a DirectShape with GeometryInstances using the DirectShapeLibrary.&lt;/P&gt;&lt;P&gt;I've realized it is possible to create GeometryInstance with a transform that has non uniform scale. This is nice, since I want to visualize geometry of a custom tool with meshes and arbitrary transform matrices.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunatly the DirectShape can't be selected in 3DView only in PlanView.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Has anyone experienced this before?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here some example code.&amp;nbsp; If you don't scale BasisX everything is fine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
class CmdTest : IExternalCommand
{
    public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
    {
        var doc = commandData.Application.ActiveUIDocument.Document;

        var p0 = new XYZ(-1, -1, 0);
        var p1 = new XYZ(1, -1, 0);
        var p2 = new XYZ(1, 1, 0);
        var p3 = new XYZ(-1, 1, 0);
        var line0 = Line.CreateBound(p0, p1);
        var line1 = Line.CreateBound(p1, p2);
        var line2 = Line.CreateBound(p2, p3);
        var line3 = Line.CreateBound(p3, p0);
        var loop = new CurveLoop();
        loop.Append(line0);
        loop.Append(line1);
        loop.Append(line2);
        loop.Append(line3);
        var loops = new CurveLoop[] { loop };
        var solid = GeometryCreationUtilities.CreateExtrusionGeometry(loops, XYZ.BasisZ, 1.0);

        using (var transaction = new Transaction(doc, "Create DS Box"))
        {
            transaction.Start();

            var dsType = DirectShapeType.Create(doc, "Box", new ElementId(BuiltInCategory.OST_GenericModel));
            dsType.SetShape([solid]);

            var dsLib = DirectShapeLibrary.GetDirectShapeLibrary(doc);
            dsLib.AddDefinitionType("Box", dsType.Id);

            var transform = new Transform(Transform.Identity);

            transform.BasisX *= 2; // stretch the box, non conformal

            var directShape = DirectShape.CreateElement(doc, new ElementId(BuiltInCategory.OST_GenericModel));
            var geoInst = DirectShape.CreateGeometryInstance(doc, "Box", transform);
            directShape.SetShape(geoInst);
            directShape.SetTypeId(dsType.Id);

            transaction.Commit();
        }

        return Result.Succeeded;
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If&lt;/P&gt;</description>
      <pubDate>Wed, 06 Nov 2024 10:27:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/directshape-with-geometryinstance-and-non-conformal-transform/m-p/13133340#M2206</guid>
      <dc:creator>thomas.hain</dc:creator>
      <dc:date>2024-11-06T10:27:49Z</dc:date>
    </item>
    <item>
      <title>Re: DirectShape with GeometryInstance and non conformal Transform</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/directshape-with-geometryinstance-and-non-conformal-transform/m-p/13134910#M2207</link>
      <description>&lt;P&gt;i have no experiencing using the DirectShapeLibrary, so i'm not entirely sure what your "Box" is. But try modifying your setshape (line 49) like so:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;directshape.SetShape(new GeometryObject[] {geoInst});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Nov 2024 23:38:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/directshape-with-geometryinstance-and-non-conformal-transform/m-p/13134910#M2207</guid>
      <dc:creator>ctm_mka</dc:creator>
      <dc:date>2024-11-06T23:38:06Z</dc:date>
    </item>
    <item>
      <title>Re: DirectShape with GeometryInstance and non conformal Transform</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/directshape-with-geometryinstance-and-non-conformal-transform/m-p/13135647#M2208</link>
      <description>&lt;P&gt;Thanks. But this doesn't work. The variable geoInst is already an IList&amp;lt;GeometryObject&amp;gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Above code with a "Box" is only a simplified example. Real structure is more complex.&lt;/P&gt;&lt;P&gt;"Box" is just an identifier to refer to a registered geometry or DirectShapeType within the Library.&lt;/P&gt;&lt;P&gt;DirectShapeLibrary enables me to crate DirectShapes with Instances referencing the Geometry of a DirectShapeType.&lt;/P&gt;&lt;P&gt;So I have many Instances with different Transforms for one Geometry. It is the same structure my external data format has. The Geometry Instance has a Transform property which an AddIn can read back.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works fine. But Instances with non conformal Transform (e.g. non uniform scale) are not selectable in the UI.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers, Tom&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Nov 2024 08:02:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/directshape-with-geometryinstance-and-non-conformal-transform/m-p/13135647#M2208</guid>
      <dc:creator>thomas.hain</dc:creator>
      <dc:date>2024-11-07T08:02:31Z</dc:date>
    </item>
  </channel>
</rss>

