Ad

Saturday, March 14, 2009

Distance Before Bearing, Never Been Wronger. Bearing before Distance, you’re in the clear

Some people are rather particular about their parcel/line labels. One example of this is wanting to always have the Bearing portion of a label before the Distance label, or vice-versa. They also want a gap between them or on either side of a direction arrow (so putting them in the same text component won't work). This doesn't always work as one would expect because the labels rotate to match the view. An example of this is in the image below. 

image 

All of the labels above are of the same style and anchored to the direction arrow. As you can see the items on the left hand side are showing correctly and the ones on the right have them swapped. One way to achieve the labels being the same is to use a text component and set it's visibility to false and anchor the bearing and distance labels to it. The picture below shows the results that we are looking for.

image

So this is one way to get the bearing and distance label components to always be in the correct location. A sample drawing with the style may be found on this page. Use the link for the second drawing, the first one didn't work correctly when the view was twisted.

Monday, March 09, 2009

vb.NET Adding a Class

In this post I'm going to try to add a Class to the VBDotNetClientSample from the last post. To add the Class right click on the project heading in Solution Explorer and choose Add and Class.

image

image

Next I need to add Acdbmgd.dll and Acmgd.dll to the project's References.

image

image 

Next we need to set up the various items needed to run code with vb.NET. There is a lot of extra things that need to be done usually done with Imports.

image

Now we can copy the code from the VBA Toggle TIN code.

image

The underlined items indicate errors in the code. Clicking the underlined words the Visual Studio (VS) gives you options on how to correct the code. In this case I'm choosing the option that the arrow is pointing to.

image

ThisDrawing doesn't have any suggestions. To get what it should be download the ObjectARX from the Autodesk website and then open the sample code provided for getting user input.

image

The sample code is in a C# file, you may need to download the Microsoft Visual Studio version for C# to open it up. The file name and location is \ObjectARX\samples\dotNet\Prompts\prompts.cs Since we are using the GetEntity do a search for it using Ctrl+F. Select the code and go to a site that will convert C# code to vb.NET. One site may be found here. As you can see below the code has grown quite a bit from the VBA version. I've commented out the code I haven't updated yet.

image

To comment out the code you can select the code and then use a button from a Toolbar in VS.

image 

Next change the Application type to Class Library. This will change the output from VS to a .dll file from an .exe.

image

Now I can compile the code and try it out in Civil 3D. The command to load the application is Netload and the typing TIN runs the program how it is currently created. I'm not sure if this will work, but you can download the dll and see if it works.

In the next post I'll try to finish the code. As you can see doing programming in vb.NET is a bit more complicated than using VBA.

Sunday, March 08, 2009

Moving from VBA to vb.NET

VBA appears to be on the way out, it's not even going to be shipping with the base AutoCAD 2010 product (but it will ship with Civil 3D 2010). There is some rumors that VSTA will be provided for AutoCAD 2010 sometime this year. I think it may be time to put VBA to down and pick up vb.NET.

The first thing that I need to do is get a separate program to work with. Microsoft provides a free version called Microsoft Visual Studio Express (VS), make sure to download the vb.net version if you go with this option. I'm going to spend some extra cash and get the full blown version. I've used both in the past and if you do program more than occasionally I've found the extra money for the full blown version can be worth it. You can try the full version for 90 days. I think you can also use other programs, but I'm not familiar with any of them.

The next step is setting up VS to program with it to work with Civil 3D. While we could spend all of the work setting it up to work with Civil 3D it's probably easier to use the sample that comes with Civil 3D. To do this open up the solution (.sln) file in the following folder:

C:\Program Files (x86)\AutoCAD Civil 3D 2009\Sample\Civil 3D API\VB_NET\VbDotNetClient

If your using Vista you may want to copy the VB_NET folder to a location that will let you freely modify the code.

Next Build, or compile, the code by going to the Build Menu and choose Build VBDotNetClientSample.

image

VS will create an EXE file in the bin folder for the project. Double click it and it will open a dialog box asking you what to do, press the Launch Autodesk Civil 3D and Civil 3D should start up.

image

Once Civil 3D starts up the Project Details button should become available. Pressing the Project Details provides the number of Point Groups and Surfaces in the drawing.

image

I don't know about you, but I usually don't have much reason to create program to open Civil 3D up. I find the icons on the desktop sufficient. I guess that the Developers figure if your using vb.NET you already know how to create a program that runs within the program.

In the next posts I'll go over some resources that have more examples on how to run the commands within Civil 3D and use them to bring the Toggle TIN Triangle Visibility code to vb.NET.

Saturday, March 07, 2009

Steering Wheel

Have you seen the Steering Wheel? I'd seen the feature but hadn't really used it since it's not in your face in Civil 3D. In the base Autocad product when you right click you get the option to use the Steering Wheel. image

I think it has some value after using it a little bit and want to add it to the default right click menu. Once way to do it may be found in a video on this page:

http://style.civil3dreminders.com/CUISteeringWheel.html

There's no sound and it's kind of small.

Thursday, March 05, 2009

Add Command Alias

Open the the following file:

C:\program files (x86)\AutoCAD Civil 3D 2009\Support\acad2009.lsp

Add the lisp to the file:

image

Open the following file:

C:\Users\MicrosoftExcel\AppData\Roaming\Autodesk\C3D 2009\enu\Support\acad.pgp

Add the following to the end of the file:

image

Close Civil 3D if open, then reopen.

Not sure why it repeats the command though.

image

LinkWithin

Blog Widget by LinkWithin

Ad