Ad

Monday, February 26, 2018

Surveying Related Ideas

Often times we need to create rectangles to represent existing features that look like rectangles.  To save time surveyors will shoot two points and then in the office convert those two points into rectangles. With lisp we can automate the rectangle creation down to picking two clicked points.

  • This forum post has some lisp code that does just that. Here is a link to a text file with the code extracted in case the forum post goes down.
  • To run the lisp save it to a text file with the extension of .lsp
  • Type Appload at the command line.
  • If you want to run it once, select the file from the upper portion of the Appload dialog box.
  • If you want the lisp to load everytime AutoCAD is run, then add the lisp file to the Startup Suite.

image

A second desired workflow is to create a point at the intersection of two selected objects, the objects don’t have to intersect. The objects may be arc, line, polyline, lot line, or feature line.

image

To start open the Point Create Creation Tools.

image

Then under the second drop down choose the Object/Object option.

image

Then follow the prompts. This will create a point where the objects intersect. If you want to remove any of the prompts you can change the settings of the Point Creation command using the double down arrow on the right of the Create Points toolbar.

Friday, February 16, 2018

Average Cut and Fill

I have no idea what the Average Cut and Average Fill of a volume surface means or how it should be calculated. It sounds like a made up term from a planner so they can come up with a made up value to judge impacts for a project. Since I don’t have a good explanation of what the average cut or fill is here is one way to do it in Civil 3D.

  1. Create the volume surface.
  2. Go into the Volume Surfaces, Analysis Tab. Change the type to Elevation, the number of Ranges to 2 and then press the down arrow to apply the 2 elevation ranges. image
    1. Change the Ranges to 0 for the Maximum Elevation for the first range and 0 for the minimum elevation for the second line. image
    2. Then create a Surface Legend table for the Elevation Analysis. image
    3. Now take the Cut Area and divide it by the volume of cut and the Fill Area and divide it by the volume of fill. Then you should have average cut/fill numbers. You can find the volume numbers in the volumes dashboard or on the Statistics tab. You can even add the volumes to the table.

    Now I have no idea if this is correct. I did end up with an average number that has the correct units. I can think of numerous other more complicated methods to calculate these values.

      Sunday, November 12, 2017

      Civil 3D API Wishlist

      My Civil 3D API Wishlist. Feel free to add your wishes in the comments.

      • Expressions – Ability to apply them to label component properties. These include, but are limited to, text height, line length, block scale, rotation angle, X Offset, Y Offset, Maximum Width, Gap, Fixed Length, Angle, Start Point X Offset, End Point X Offset, Start Point Y Offset, End Point Y Offset, and anyone that I missed.
      • Profile View Bands – Ability to get a label by station.
      • Profile View Bands – Labels having properties applicable to what they are labeling. Such as Station, Offset, Curve Length, etc… (Maybe a way to get the available properties in the UI in a method call).
      • Profile View Bands – Pipe Network – Ability to add invert elevations to the band at Structure Walls (inside and outside).
      • Survey Database – Finish it (or probably start it) for .NET. Have the ability to everything in the UI in the API.
      • Pressure Pipe Network – Document it in the other portion of the API as well as finishing it. Have the ability to everything in the UI in the API.
      • Data Shortcuts – Add the ability to create a reference.
      • Data Shortcuts – Add the ability to change the current Data Shortcuts Working Folder (without using the XML hack).
      • Data Shortcuts – Ability to create data shortcuts for use in other drawings.
      • Feature Lines – Fix the add PI method to work correctly. Currently it appears to find the closest point and will put the PI in the wrong location.
      • Surface Analysis – Lighten up on the rules on when analysis are added to the rows. I should be able to create a long list, even if not applicable to the current surface. This way the code could be run easier.
      • Surface Analysis – Add the missing analysis types to the API.
      • Point Label Location – Fix it so you can apply the current location without having to reset with each property change. Currently it moves relative to the last location.
      • Profile – A method to find the currently selected profile view based on profile selected.
      • QTO – Create an API so it can be expanded and easily assigned to objects. Ability to extract the data from the drawing(s).
      • Profile – Allow for the station to be before or after the end of the alignment. The exception that is provided here is not productive. Especially when the station is 1+01.999 and the user wants to use 1+02.00.
      • Intersection – Allow the API to create an Intersection.
      • Linked Alignments  – Allow the API to create.
      • Linked Profiles – Allow the API to create.
      • UDP – Make more robust to changes.
      • Parcels – Finish the .NET API.
      • Subassemblies – Allow for the cleanup of the properties window after a subassembly is swapped out with a new one.

      Tuesday, October 17, 2017

      Style Changes

      Have you ever wanted to change styles quickly? Maybe you want go from OldStyle to NewStyle, but don’t want to do it manually. Well here is maybe one way to quickly change styles for lots of objects using a LispFunction. A LispFuntion allows Lisp to talk to .NET.

      In this case we can use fancy inheritance to set the style name of any object type we want. We do this by using the fact that most Civil 3D objects are a type of Autodesk.Civil.DatabaseServices.Entity which contains the StyleName property. Luckily this property takes a string and Civil 3D takes care of finding the correct style to use based on the name given. If the style isn’t in the drawing an exception will occur and an error message sent to the command line.

      After loading the dll you can then type at the command line:

      (ChangeCivil3DStyleByName “AECC_ALIGNMENT” “OldStyleName” “NewStyleName”)

      Then press enter. Then each alignment with the OldStyleName will be magically changed to the NewStyleName. If you have lots of objects to change I’d build a list in Excel with the appropriate object type and style names and use the Concatenate formula to build the above lines. Then you can add it to a lisp or copy and paste at the command line.

      To get the object type names (like AECC_ALIGNMENT), select the object and then type List at the command line. The first line should give you the value.

      public class StyleChanges

      {

           [LispFunction("ChangeCivil3DStyleByName")]

           public void ChangeStyleName(ResultBuffer rbArgs)

           {

                if (rbArgs == null) {

                Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("\nNo objects passed");

           }

           var rbArgsList = rbArgs.AsArray().ToList();

           if (rbArgsList.Count() != 3)

           {

                Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("\nNeed three objects to be passed.");

           }    

           try

           {

                var civDoc = CivilApplication.ActiveDocument;

                var objectType = rbArgsList[0].Value.ToString();

                var oldStyleName = rbArgsList[1].Value.ToString();

                var newStyleName = rbArgsList[2].Value.ToString();

                // Aec.DatabaseServices.Entity

                var doc = Application.DocumentManager.MdiActiveDocument;

                var ed = doc.Editor;

                using (var tr = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction())

                {

                     // Need to get the objects

                     TypedValue[] vals = new TypedValue[]

                     {

                          new TypedValue((int)DxfCode.Start, objectType)

                     };

                     var res = ed.SelectAll(new SelectionFilter(vals));

                     if (res.Status == PromptStatus.OK) { foreach (ObjectId objId in res.Value.GetObjectIds())

                     {

                          var aecObj = objId.GetObject(OpenMode.ForRead) as Autodesk.Civil.DatabaseServices.Entity;

                          if (aecObj.StyleName == oldStyleName)

                          {

                               aecObj.UpgradeOpen();

                               aecObj.StyleName = newStyleName;

                          }

                     }

               }

          tr.Commit();

      }

      }

      catch (System.Exception ex) { Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("\nError: " + ex.Message); } } }

      Tuesday, August 15, 2017

      Property Set Formulas

      Sometime in the recent past Autodesk enabled and advocated the use of Property Sets. It’s kind of sad why Autodesk did this, but that is another story about the lack of BIM in Civil 3D. I recently learned one can create formulas in the Property Sets and use VBScripts in the formulas. We can then use these scripts to extract information from objects. In this post I’m going to show how you can create a script to show a Pipe’s Material.

      The first step is to type PropertySetDefine at the command line. This will bring up the Style Manager. image

      Right click on the Property Set Definitions and select the New option. I’m using the default name of New Style. In the script I will want to use the ObjectID of the object. Note that this ObjectID is different than ObjectId found in .NET. To add this property click on the Applies To tab of the Property Set Definition select Pipe.

      image

      Then press the Add Automatic Property Definition button and select Object ID from the list.

      image

      We will need this property in the script. So now we can create a script. Note that if you don’t want to see the property in the Properties palette you can check the Visible check box to unchecked.

      image

      Now press the Add Formula Property Definition button. Then Right Click, in the Insert Property Defintions, on the ObjectID and select Insert. This will add the ObjectID to the formula box and in the Enter Sample Values list.

      image

      Next insert the following formula in the formula box. Remove the [ObjectID] from the previous step. Make sure each line

      RESULT="—"

      On Error Resume Next

      Set oApp=GetObject(, "AutoCAD.Application")

      Set oCivilApp=oApp.GetInterfaceObject("AeccXUiLand.AeccApplication.11.0")

      Set obj=oCivilApp.ActiveDocument.ObjectIdToObject("[ObjectID]")

      RESULT=obj.PartDataRecord.FindByContext(300).Tag

      If the text ends up large press OK and then go back into the dialog box. This will reset the text height to the default size. Then go into the drawing and apply the property set by selecting a pipe and pressing the Add Property Set button.

      image

      Then the Material name should show up in the box.

      image

      You can find the list of standard Context here: http://blog.civil3dreminders.com/2016/03/freaking-context-values.html if you want to use a different value.

      Here is a video showing the steps: https://www.youtube.com/watch?v=v97WpUgk0w8

      LinkWithin

      Blog Widget by LinkWithin

      Ad