<?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: create an inclined cylinder by using extrusion in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/create-an-inclined-cylinder-by-using-extrusion/m-p/7782647#M27502</link>
    <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="InclinedCylinder.JPG" style="width: 378px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/463752i8DA3C2C49E31A8CC/image-size/large?v=v2&amp;amp;px=999" role="button" title="InclinedCylinder.JPG" alt="InclinedCylinder.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;To Create something similar as above, I have quickly written the code, there code be some redundancies.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;[CommandMethod("TCY")]
        public static void createTCY()
        {
            // Get the current document and database, and start a transaction
            Document acDoc = Application.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;

            using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
            {
                // Open the Block table record for read
                BlockTable acBlkTbl;
                acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,
                                                OpenMode.ForRead) as BlockTable;

                // Open the Block table record Model space for write
                BlockTableRecord acBlkTblRec;
                acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],
                                                OpenMode.ForWrite) as BlockTableRecord;

                // Create a 3D solid Inclined
                using (Solid3d acSol3D = new Solid3d())
                {

                    //Switch UCS
                    Matrix3d curUCSMatrix = acDoc.Editor.CurrentUserCoordinateSystem;
                    CoordinateSystem3d curUCS = curUCSMatrix.CoordinateSystem3d;
                    CoordinateSystem3d newUCS = new CoordinateSystem3d(new Point3d(10, 10, 10), curUCS.Xaxis, curUCS.Zaxis);
                    Matrix3d newUCSMatrix = Matrix3d.AlignCoordinateSystem(curUCS.Origin, curUCS.Xaxis, curUCS.Yaxis, curUCS.Zaxis, newUCS.Origin, newUCS.Xaxis, newUCS.Yaxis, newUCS.Zaxis);
                    acDoc.Editor.CurrentUserCoordinateSystem = newUCSMatrix;

                    using (Line l = new Line())
                    {
                        l.StartPoint = new Point3d(10, 10, 10);
                        l.EndPoint = new Point3d(120.0, -30.0, 120.0);
                        acDoc.Editor.CurrentUserCoordinateSystem = curUCSMatrix;


                        // Create an in memory circle
                        using (Circle acCirc = new Circle())
                        {
                            acCirc.Center = new Point3d(10.0, 10.0, 0);
                            acCirc.Radius = 60;

                            // Adds the circle to an object array
                            DBObjectCollection acDBObjColl = new DBObjectCollection();
                            acDBObjColl.Add(acCirc);

                            // Calculate the regions based on each closed loop
                            DBObjectCollection myRegionColl = new DBObjectCollection();
                            myRegionColl = Region.CreateFromCurves(acDBObjColl);
                            Region acRegion = myRegionColl[0] as Region;
                            // Add the new object to the block table record and the transaction
                            
                            ObjectId regionId = acBlkTblRec.AppendEntity(acRegion);
                            acTrans.AddNewlyCreatedDBObject(acRegion, true);
                            acRegion = acTrans.GetObject(regionId, OpenMode.ForRead) as Region;

                            //Solid creation by curve
                            acSol3D.ExtrudeAlongPath(acRegion, l, 0.0);
                            // Add the new object to the block table record and the transaction
                            acBlkTblRec.AppendEntity(acSol3D);
                            acTrans.AddNewlyCreatedDBObject(acSol3D, true);
                        } // Dispose of the in memory circle not appended to the database
                    }


                }

                // Save the new objects to the database
                acTrans.Commit();
            }
        }
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 16 Feb 2018 07:01:10 GMT</pubDate>
    <dc:creator>moogalm</dc:creator>
    <dc:date>2018-02-16T07:01:10Z</dc:date>
    <item>
      <title>create an inclined cylinder by using extrusion</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-an-inclined-cylinder-by-using-extrusion/m-p/7762019#M27500</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to create a solid3D which represents a cylinder. This solid 3D object should be either vertical or inclined.&lt;/P&gt;&lt;P&gt;For the vertical case, I use the method Solid3D.extrude(...), and it works well. For the inclined case, I have tried to use the method Solid3D.ExtrudeByPath(...). But it doesn't work. I wonder if I can use an inlined line (by defining the start and the end point3D) as the Path of extrusion? And if there are some successful example that somebody can show me here?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;Beiting.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 13:01:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-an-inclined-cylinder-by-using-extrusion/m-p/7762019#M27500</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-02-08T13:01:13Z</dc:date>
    </item>
    <item>
      <title>Re: create an inclined cylinder by using extrusion</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-an-inclined-cylinder-by-using-extrusion/m-p/7767394#M27501</link>
      <description>&lt;P&gt;Posting a sample (dwg or image) showing what you're trying to do wold be helpful, as I'm not completely sure what 'inclined cylinder' means.&lt;/P&gt;</description>
      <pubDate>Sat, 10 Feb 2018 05:36:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-an-inclined-cylinder-by-using-extrusion/m-p/7767394#M27501</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2018-02-10T05:36:42Z</dc:date>
    </item>
    <item>
      <title>Re: create an inclined cylinder by using extrusion</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-an-inclined-cylinder-by-using-extrusion/m-p/7782647#M27502</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="InclinedCylinder.JPG" style="width: 378px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/463752i8DA3C2C49E31A8CC/image-size/large?v=v2&amp;amp;px=999" role="button" title="InclinedCylinder.JPG" alt="InclinedCylinder.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;To Create something similar as above, I have quickly written the code, there code be some redundancies.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;[CommandMethod("TCY")]
        public static void createTCY()
        {
            // Get the current document and database, and start a transaction
            Document acDoc = Application.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;

            using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
            {
                // Open the Block table record for read
                BlockTable acBlkTbl;
                acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,
                                                OpenMode.ForRead) as BlockTable;

                // Open the Block table record Model space for write
                BlockTableRecord acBlkTblRec;
                acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],
                                                OpenMode.ForWrite) as BlockTableRecord;

                // Create a 3D solid Inclined
                using (Solid3d acSol3D = new Solid3d())
                {

                    //Switch UCS
                    Matrix3d curUCSMatrix = acDoc.Editor.CurrentUserCoordinateSystem;
                    CoordinateSystem3d curUCS = curUCSMatrix.CoordinateSystem3d;
                    CoordinateSystem3d newUCS = new CoordinateSystem3d(new Point3d(10, 10, 10), curUCS.Xaxis, curUCS.Zaxis);
                    Matrix3d newUCSMatrix = Matrix3d.AlignCoordinateSystem(curUCS.Origin, curUCS.Xaxis, curUCS.Yaxis, curUCS.Zaxis, newUCS.Origin, newUCS.Xaxis, newUCS.Yaxis, newUCS.Zaxis);
                    acDoc.Editor.CurrentUserCoordinateSystem = newUCSMatrix;

                    using (Line l = new Line())
                    {
                        l.StartPoint = new Point3d(10, 10, 10);
                        l.EndPoint = new Point3d(120.0, -30.0, 120.0);
                        acDoc.Editor.CurrentUserCoordinateSystem = curUCSMatrix;


                        // Create an in memory circle
                        using (Circle acCirc = new Circle())
                        {
                            acCirc.Center = new Point3d(10.0, 10.0, 0);
                            acCirc.Radius = 60;

                            // Adds the circle to an object array
                            DBObjectCollection acDBObjColl = new DBObjectCollection();
                            acDBObjColl.Add(acCirc);

                            // Calculate the regions based on each closed loop
                            DBObjectCollection myRegionColl = new DBObjectCollection();
                            myRegionColl = Region.CreateFromCurves(acDBObjColl);
                            Region acRegion = myRegionColl[0] as Region;
                            // Add the new object to the block table record and the transaction
                            
                            ObjectId regionId = acBlkTblRec.AppendEntity(acRegion);
                            acTrans.AddNewlyCreatedDBObject(acRegion, true);
                            acRegion = acTrans.GetObject(regionId, OpenMode.ForRead) as Region;

                            //Solid creation by curve
                            acSol3D.ExtrudeAlongPath(acRegion, l, 0.0);
                            // Add the new object to the block table record and the transaction
                            acBlkTblRec.AppendEntity(acSol3D);
                            acTrans.AddNewlyCreatedDBObject(acSol3D, true);
                        } // Dispose of the in memory circle not appended to the database
                    }


                }

                // Save the new objects to the database
                acTrans.Commit();
            }
        }
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2018 07:01:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-an-inclined-cylinder-by-using-extrusion/m-p/7782647#M27502</guid>
      <dc:creator>moogalm</dc:creator>
      <dc:date>2018-02-16T07:01:10Z</dc:date>
    </item>
    <item>
      <title>Re: create an inclined cylinder by using extrusion</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-an-inclined-cylinder-by-using-extrusion/m-p/7822032#M27503</link>
      <description>&lt;P&gt;Hi, I have been absent for a moment. Sorry for not replying to you quickly. Thank you so much for your solution. It seems work in my case. Thanks again!&lt;/P&gt;</description>
      <pubDate>Fri, 02 Mar 2018 10:25:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-an-inclined-cylinder-by-using-extrusion/m-p/7822032#M27503</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-03-02T10:25:21Z</dc:date>
    </item>
  </channel>
</rss>

