Ad

Wednesday, February 06, 2013

Getting Civil 3D Objects From XREFs

While not advised, it is possible to get Civil 3D objects from an XREF. I’m not sure of the ramifications of modifying object after getting them in this manner, but one is able to read the Civil 3D object’s information. The code below goes and gets a variety of objects from an XREF and returns their ObjectIds. I even limit the returned values based on the layer they are on.

   1:          private static void FindObjectsInXREF(GraphNode root, string layerName, string xrefName, out List<ObjectId> polyObjIds)


   2:          {


   3:              polyObjIds = new List<ObjectId>();


   4:              for (int o = 0; o < root.NumOut; o++)


   5:              {


   6:                  XrefGraphNode child = root.Out(o) as XrefGraphNode;


   7:                  if (child.XrefStatus == XrefStatus.Resolved && child.Name == xrefName)


   8:                  {


   9:                      BlockTableRecord bl = child.BlockTableRecordId.GetObject(OpenMode.ForRead) as BlockTableRecord;


  10:                      foreach (ObjectId objId in bl)


  11:                      {


  12:                          Autodesk.AutoCAD.DatabaseServices.Entity ent = objId.GetObject(OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;


  13:                          Type entType = ent.GetType();


  14:                          if (ent.Layer == xrefName + "|" + layerName && (entType == typeof(Polyline) || 


  15:                                                                          entType == typeof(Polyline) || 


  16:                                                                          entType == typeof(Alignment) || 


  17:                                                                          entType == typeof(Polyline3d) || 


  18:                                                                          entType == typeof(Polyline2d)))


  19:                          {


  20:                              polyObjIds.Add(objId);


  21:                          }


  22:                      }


  23:                  }


  24:              }


  25:          }




asdf

Tuesday, February 05, 2013

Select Viewport

Here’s some code to select a viewport. I’ve made an extension to the Editor class. this way I can easily call it from other code. Most of the rest of the code was taken from an internet search when I was coding for viewport selection. I’m unsure of the original source, although a search of words finds it in numerous locations.

        public static ObjectId SelectViewport(this Editor ed, string promptString)
{
ObjectId viewportObjId = ObjectId.Null;
PromptEntityOptions opt = new PromptEntityOptions("\n" + promptString);
opt.SetRejectMessage("\nObject must be a viewport.\n");
opt.AddAllowedClass(typeof(Viewport), true);
//next lines are to allow for non-rectangular viewport selection
opt.AddAllowedClass(typeof(Circle), true);
opt.AddAllowedClass(typeof(Polyline), true);
opt.AddAllowedClass(typeof(Polyline2d), true);
opt.AddAllowedClass(typeof(Polyline3d), true);
opt.AddAllowedClass(typeof(Ellipse), true);
opt.AddAllowedClass(typeof(Autodesk.AutoCAD.DatabaseServices.Region), true);
opt.AddAllowedClass(typeof(Spline), true);
opt.AddAllowedClass(typeof(Face), true);
PromptEntityResult viewportResult = ed.GetEntity(opt);

if (viewportResult.Status == PromptStatus.OK)
{
Entity ent = viewportResult.ObjectId.GetObject(OpenMode.ForRead) as Entity;
// It is a rectangular viewport.
if (ent.GetType() == typeof(Viewport))
{
viewportObjId = viewportResult.ObjectId;
}
else if (true)
{
//Viewport is non-rectangular, attempt to get it from the selected clip entity
ObjectId vpId = LayoutManager.Current.GetNonRectangularViewportIdFromClipId(viewportResult.ObjectId);
if (vpId != ObjectId.Null)
{
viewportObjId = vpId;
}
}
}
return viewportObjId;
}



It also provides a nice example to limit different types of objects during selection. Just remove the opt.AddAllowedClass(typeof(Spline), true);  you don’t need and add the classes you want the user to select. It makes it easy so you have to worry less about the user selecting the wrong type of object. Just make sure to provide the error warning message first.

Thursday, January 24, 2013

Three Ring Circus

Some exhibitors at Autodesk University are similar to small elementary school fairs, such as Quux Software. Other exhibitors have a three ring circus such as Hewlett Packard, also known as HP.  It’s not surprising that HP would have a large presence at Autodesk University with the wide range of products they provide. They sell printers, plotters, laptops, and workstations! Oh my!

Being a super small business, I found the HP Designjet T120 intriguing. A small footprint to not clutter up a small office too much with the ability to print out full size plans. While I’m not a fan of full size plans, I have printed out quite a number of sheets this year at the local blue print location. There is also the T520 ePrinter series. There’s lots of great features in these printers. Click the links to find out more.

I was also interested in the HP Z1 Workstation. If I had a small office I’d probably look into the Z1 workstation. It’s got a small footprint since the computer is included in the monitor. So it would remove some of the cables. It would also make moving the computer easier. Plus opening it up shows that most of the innards are easy to access.

I’m too lazy this evening to add pictures to this post. Feel free to mosey on over the HP’s website to get some fancy pictures of the products.

Tuesday, January 22, 2013

App Store Structure Report

There’s a new App in the Autodesk App Store for Civil 3D 2013. This gem of a program creates a visual representation of structures and I’ve dubbed it Create Structure Report. I know you are all jealous of my creative skills as demonstrated by this glorious name. It’s also a steal at $25 for the download.

The sample output of the report may be found at this link. The user selects the structures they wish to have a report created for. The incoming and outgoing pipes are then shown in the report. You can tell the direction of the pipe by the words IN and OUT as well as the fancy colored arrows. The width of the pipe is also shown so you can visually see how far apart the pipes are going to be. The enormous white space at the top gives you plenty of room to draw doodles, or if you are more practical have your companies logo. There’s even a place to put some job information on the form. If you have numerous structures the report sheets may be put into an open Sheet Set. Plus if you ask really nicely you can get the source code of the project. This app is open source project, so feel free to contribute any bug fixes or additional features.

Monday, January 21, 2013

Put a Wrapper on It!

I’ve been using Google Docs for the past 10 months and with cloud services becoming a major focus, all I can ask of software developers is to put a Wrapper on the dang browser. The UI elements of a browser really suck for word processing, spreadsheets, and CAD programs. The ease of use just isn’t there like there is in a Windows or Mac based program. I quick and snappy right click menus. I miss the ability to use keyboard shortcuts to add and remove rows in a spreadsheet. If I wanted to back in time, in a UI perspective, I’d buy a 386 and get a version of CADKEY to put on it.

Maybe it’s time for the browser to be acknowledge as a poor delivery of a UI interface for programs and have UI wrapper put on top of it to provide a 21st Century experience. I’m all for change, but I prefer change for the better, not going back in time to a 1.0 version of Excel. A UI wrapper for a web delivered program would go a long way in upgrading the cloud experience. That’s just my 2 cents.

LinkWithin

Blog Widget by LinkWithin

Ad