<?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 creating ordinate dimensions in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/creating-ordinate-dimensions/m-p/6729253#M33654</link>
    <description>&lt;P&gt;Hi folks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm having a little trouble creating an ordinate dimension.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want the ordinate dimension to be on the UCS not the WCS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; [CommandMethod("CreateOrdinateDimension")]
        public static void CreateOrdinateDimension()
        {
            // Get the current database
            Document acDoc = Application.DocumentManager.MdiActiveDocument;
            Editor ed = acDoc.Editor;
            Database acCurDb = acDoc.Database;

            // Start a transaction
            using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
            {
                // Open the Block table 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 an ordinate dimension
                using (OrdinateDimension acOrdDim = new OrdinateDimension())
                {
                    acOrdDim.UsingXAxis = true;

                    //// this seems to print the dimension at the WCS origin?
                    //acOrdDim.DefiningPoint = new Point3d(0,0,0);
                    //acOrdDim.LeaderEndPoint = new Point3d(0, 0, 0);

                    ////this seems to print at the UCS origin, but the numbers used are in fact WCS?
                    acOrdDim.DefiningPoint = new Point3d(0, 0, 0).TransformBy(ed.CurrentUserCoordinateSystem);
                    acOrdDim.LeaderEndPoint = new Point3d(0, 0, 0).TransformBy(ed.CurrentUserCoordinateSystem);

                    acOrdDim.DimensionStyle = acCurDb.Dimstyle;

                    // Add the new object to Model space and the transaction
                    acBlkTblRec.AppendEntity(acOrdDim);
                    acTrans.AddNewlyCreatedDBObject(acOrdDim, true);
                }

                // Commit the changes and dispose of the transaction
                acTrans.Commit();
            }
        }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Attached is my drawing file.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;The circle centre marks the WCS origin.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The problem&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;when i transform the defining and leader points by UCS, it does print to the UCS origin, but it is not saying 0. It is giving me the WCS numbers.&lt;/LI&gt;&lt;LI&gt;When I do not transform by UCS, the correct numbers are shown, but it displays it at the WCS origin, not the UCS origin.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want it to print at the UCS origin, &lt;EM&gt;and&lt;/EM&gt; have it also display 0 at the same time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;assistance much appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;chrs&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 05 Dec 2016 22:45:17 GMT</pubDate>
    <dc:creator>BKSpurgeon</dc:creator>
    <dc:date>2016-12-05T22:45:17Z</dc:date>
    <item>
      <title>creating ordinate dimensions</title>
      <link>https://forums.autodesk.com/t5/net-forum/creating-ordinate-dimensions/m-p/6729253#M33654</link>
      <description>&lt;P&gt;Hi folks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm having a little trouble creating an ordinate dimension.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want the ordinate dimension to be on the UCS not the WCS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; [CommandMethod("CreateOrdinateDimension")]
        public static void CreateOrdinateDimension()
        {
            // Get the current database
            Document acDoc = Application.DocumentManager.MdiActiveDocument;
            Editor ed = acDoc.Editor;
            Database acCurDb = acDoc.Database;

            // Start a transaction
            using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
            {
                // Open the Block table 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 an ordinate dimension
                using (OrdinateDimension acOrdDim = new OrdinateDimension())
                {
                    acOrdDim.UsingXAxis = true;

                    //// this seems to print the dimension at the WCS origin?
                    //acOrdDim.DefiningPoint = new Point3d(0,0,0);
                    //acOrdDim.LeaderEndPoint = new Point3d(0, 0, 0);

                    ////this seems to print at the UCS origin, but the numbers used are in fact WCS?
                    acOrdDim.DefiningPoint = new Point3d(0, 0, 0).TransformBy(ed.CurrentUserCoordinateSystem);
                    acOrdDim.LeaderEndPoint = new Point3d(0, 0, 0).TransformBy(ed.CurrentUserCoordinateSystem);

                    acOrdDim.DimensionStyle = acCurDb.Dimstyle;

                    // Add the new object to Model space and the transaction
                    acBlkTblRec.AppendEntity(acOrdDim);
                    acTrans.AddNewlyCreatedDBObject(acOrdDim, true);
                }

                // Commit the changes and dispose of the transaction
                acTrans.Commit();
            }
        }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Attached is my drawing file.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;The circle centre marks the WCS origin.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The problem&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;when i transform the defining and leader points by UCS, it does print to the UCS origin, but it is not saying 0. It is giving me the WCS numbers.&lt;/LI&gt;&lt;LI&gt;When I do not transform by UCS, the correct numbers are shown, but it displays it at the WCS origin, not the UCS origin.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want it to print at the UCS origin, &lt;EM&gt;and&lt;/EM&gt; have it also display 0 at the same time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;assistance much appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;chrs&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Dec 2016 22:45:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/creating-ordinate-dimensions/m-p/6729253#M33654</guid>
      <dc:creator>BKSpurgeon</dc:creator>
      <dc:date>2016-12-05T22:45:17Z</dc:date>
    </item>
    <item>
      <title>Re: creating ordinate dimensions</title>
      <link>https://forums.autodesk.com/t5/net-forum/creating-ordinate-dimensions/m-p/6729748#M33655</link>
      <description>&lt;P&gt;Can you please try to set identity matrix to the current UCS before defining the ordinate DefiningPoint and LeaderEndPoint in &amp;nbsp;your code ?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ed.CurrentUserCoordinateSystem = Matrix3d.Identity&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Here is the modified code:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;[CommandMethod("CreateOrdinateDimension")]
		public static void CreateOrdinateDimension()
		{
			// Get the current database
			Document acDoc = Application.DocumentManager.MdiActiveDocument;
			Editor ed = acDoc.Editor;
			Database acCurDb = acDoc.Database;

			// Start a transaction
			using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
			{
				// Open the Block table 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 an ordinate dimension
				using (OrdinateDimension acOrdDim = new OrdinateDimension())
				{
					acOrdDim.UsingXAxis = true;

					ed.CurrentUserCoordinateSystem = Matrix3d.Identity;

					//// this seems to print the dimension at the WCS origin?
					acOrdDim.DefiningPoint = new Point3d(0, 0, 0);
					acOrdDim.LeaderEndPoint = new Point3d(0, 0, 0);

					////this seems to print at the UCS origin, but the numbers used are in fact WCS?
					//acOrdDim.DefiningPoint = new Point3d(0, 0, 0).TransformBy(ed.CurrentUserCoordinateSystem);
					//acOrdDim.LeaderEndPoint = new Point3d(0, 0, 0).TransformBy(ed.CurrentUserCoordinateSystem);

					acOrdDim.DimensionStyle = acCurDb.Dimstyle;


					// Add the new object to Model space and the transaction
					acBlkTblRec.AppendEntity(acOrdDim);
					acTrans.AddNewlyCreatedDBObject(acOrdDim, true);
				}

				// Commit the changes and dispose of the transaction
				acTrans.Commit();
			}
		}&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Dec 2016 06:01:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/creating-ordinate-dimensions/m-p/6729748#M33655</guid>
      <dc:creator>deepak.a.s.nadig</dc:creator>
      <dc:date>2016-12-06T06:01:16Z</dc:date>
    </item>
    <item>
      <title>Re: creating ordinate dimensions</title>
      <link>https://forums.autodesk.com/t5/net-forum/creating-ordinate-dimensions/m-p/6741887#M33656</link>
      <description>&lt;P&gt;Hello thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The solution did not work for me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will present the problem and the solution which did work as soon as able.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;with kind regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BK&lt;/P&gt;</description>
      <pubDate>Sun, 11 Dec 2016 13:13:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/creating-ordinate-dimensions/m-p/6741887#M33656</guid>
      <dc:creator>BKSpurgeon</dc:creator>
      <dc:date>2016-12-11T13:13:59Z</dc:date>
    </item>
    <item>
      <title>Re: creating ordinate dimensions</title>
      <link>https://forums.autodesk.com/t5/net-forum/creating-ordinate-dimensions/m-p/6741935#M33657</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want the dimension to be related to current UCS coordinates, you have to tranform&amp;nbsp;the defining and leader end points to UCS coordinates.&lt;/P&gt;
&lt;P&gt;If you want the ordinate dimension&amp;nbsp;origin to be the same as the UCS origin you have to set the OrdinateDimension.Origin&amp;nbsp;property.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;        public void CreateOrdinateDimension()
        {
            var doc = AcAp.DocumentManager.MdiActiveDocument;
            var db = doc.Database;
            var ed = doc.Editor;

            var ptRes = ed.GetPoint("\nSpecify feature location: ");
            if (ptRes.Status != PromptStatus.OK)
                return;
            var pt = ptRes.Value.TransformBy(ed.CurrentUserCoordinateSystem);

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                var ms = (BlockTableRecord)tr.GetObject(
                    SymbolUtilityServices.GetBlockModelSpaceId(db), OpenMode.ForWrite);
                
                using (OrdinateDimension dim = new OrdinateDimension())
                {
                    dim.UsingXAxis = true;
                    dim.DefiningPoint = pt;
                    dim.LeaderEndPoint = pt;
                    dim.Origin = Point3d.Origin.TransformBy(ed.CurrentUserCoordinateSystem);

                    dim.DimensionStyle = db.Dimstyle;

                    ms.AppendEntity(dim);
                    tr.AddNewlyCreatedDBObject(dim, true);
                }
                    tr.Commit();
            }
        }&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Dec 2016 15:08:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/creating-ordinate-dimensions/m-p/6741935#M33657</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2016-12-11T15:08:13Z</dc:date>
    </item>
  </channel>
</rss>

