Ad

Sunday, September 30, 2012

ExtractC3DSurfBoundaries

I’ve created my first app for sale on the AutoCAD Exchange Apps Store. The app is a single command which extracts all of the boundaries from surfaces in a drawing. It’s a fairly light weight app that I use on occasion to combine into an overall surface boundary. The program is compatible with Civil 3D 2013.

I’m working on a more involved App used in River Sections which is almost complete. A video of what this future can do may be found here: http://civilintentions.blogspot.com/2012/09/river-sections-for-civil-3d.html

Wednesday, September 19, 2012

Inappropriate Comedy - Agency Disclaimers

Not quite sure if additions to review agency required notes would be found funny or frowned upon.

image

Tuesday, September 18, 2012

Pointless Details

I’m trying my hand at comedy. Not quite sure if my details are the correct outlet though.

image

Sunday, September 16, 2012

SAC–Define Variable Value

Occasionally it can get fairly confusing on what a variable a value should be or I don’t want to use a Decision Workflow node. In these cases I’ll use a Define Variable. By defining a variable I’m able to encapsulate what a value should be throughout a subassembly without having a decision point and two different branches going out. In previous post I created an example for a decision workflow that adjusted an Y value. This is troublesome in that I now have to sets of node to show the same geometry. By using a Define Variable, I can avoid this problem. I replace my Decision with what is shown below.

image

image

image

I find it easier to work with SAC when I encapsulate the variables and not use decisions. I find it makes it easier to read what the subassembly is supposed to do and reduces the amount of points and links that are in it. There is also a performance hit the more points and links that are in the file, so using this method helps in the performance of creating complex subassemblies.

SAC–IsLayout and Conditionals

Sometimes using Subassembly Composer we can do some quite complex things. Often times we want to show a scenario in Layout mode and combine it with if targets are valid during roadway mode. To do this we can combine If statements by using the keywords AND or OR. This way we can use the same code and control how the subassembly will be shown in both layout and roadway.

For instance if I want to have a branch where I want to show a branch if in Layout or if the Offset Alignment target I’ve added to the Subassembly is valid. I’d use this string:

(SA.IsLayout)OR(OffsetAlignment.IsValid)

image

This provides the ability to control how the subassembly will be shown in Layout and Roadway Mode.

Here’s an untested SAC file for your use. If Google doesn’t let you download at first refresh the page and Google should change it’s mind and let you download the file.

Saturday, September 15, 2012

Adding a Profile PVI Through the API

The code below shows how to add a PVI to an existing profile. The code has the user select a profile and then the profile view the profile is in. Then using the picked point, or somewhere near it, a PVI is added to the profile.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.AutoCAD.Runtime;
using System.Windows.Forms;
using acadApp = Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.Civil.ApplicationServices;
using Autodesk.Civil.DatabaseServices;
using Autodesk.AutoCAD.Geometry;

namespace TestBands
{
public class TestBands
{
[CommandMethod("TestBands")]
public void TestBandsCommand()
{
CivilDocument civDoc = CivilApplication.ActiveDocument;
Database db = acadApp.Application.DocumentManager.MdiActiveDocument.Database;
Editor ed = acadApp.Application.DocumentManager.MdiActiveDocument.Editor;
using (Transaction tr = db.TransactionManager.StartTransaction())
{
ProfileView profView = null;
Point3d ptSelected = new Point3d(0,0,0);
ObjectId profileObjId = SelectProfile(civDoc, "Select profile section to edit: ", out profView, out ptSelected);

Profile profSection = profileObjId.GetObject(OpenMode.ForRead) as Profile;
double dElev = double.MinValue;
double dSta = double.MinValue;

profView.FindStationAndElevationAtXY(ptSelected.X, ptSelected.Y, ref dSta, ref dElev);

profSection.PVIs.AddPVI(dSta, dElev + 10);

ed.Regen();
ed.UpdateScreen();
tr.Commit();
}
}

public static ObjectId SelectProfile(CivilDocument civDoc, string prompt, out ProfileView profView, out Point3d ptSelected)
{
Editor ed = acadApp.Application.DocumentManager.MdiActiveDocument.Editor;
ptSelected = new Point3d(0,0,0);
try
{
PromptEntityOptions pops = new PromptEntityOptions("\n" + prompt);
profView = null;
pops.Message = "\nYou must select a Profile View:";
PromptEntityResult profileRes = ed.GetEntity(pops);

if (profileRes.Status == PromptStatus.OK)
{
// Get the profile view of the profile.
Profile prof = profileRes.ObjectId.GetObject(OpenMode.ForRead) as Profile;
Alignment align = prof.AlignmentId.GetObject(OpenMode.ForRead) as Alignment;
profView = ed.GetEntity(pops).ObjectId.GetObject(OpenMode.ForRead) as ProfileView;
ptSelected = profileRes.PickedPoint;
return profileRes.ObjectId;
}
return ObjectId.Null;


}
catch (Autodesk.AutoCAD.Runtime.Exception exe)
{
ed.WriteMessage("Error creating alignment: " + exe.Message);
}
catch (System.Exception ex)
{
ed.WriteMessage("Error creating alignment: " + ex.Message);
}
profView = null;
return ObjectId.Null;
}
}
}



This example is from a larger project that exports Civil 3D information to ISIS, MIKE, and HEC-RAS. It’s also being used as an example of how the bands do not update when using the API. To update the bands after adding a PVI one has to go into the Profile View Properties. This will cause the bands to reflect changes made using the API.

LinkWithin

Blog Widget by LinkWithin