Monday, 28 February 2011

Swap Civil3d Subassemblies in an existing Road Cross Section Assembly

I know that you have the swap part button for Civil3d pipes but where the heck is the swap part button for subassemblies, very will hidden indeed.
Say you have a cross section assembly with one subassembly buried in the middle of it that you want to swap to something else. For example a central median kerb to be swapped from kerb and channel to nib. How do you swap the part easily without rebuild the whole assembly.
1. Press Ctrl+3 to open the Tool Palette.
2. Go to the part you want to swap too.
3. Right Click and select “Apply Tool Properties to Subassembly”
4. Select the subassembly in the drawing to be swapped out and click.
5. Bingo you are done and have the new Subassembly in the overall assembly.

Thursday, 24 February 2011

Offsetting Profiles or Projected Featurelines in ProfileViews

You cannot offset profiles or projected featureline’s in profileviews (that I know of) which is a real pain, especially when you are wanting to check ground cover above existing services to your design profile or surface. To get round this you can
1. Copy the design profile and then raise or lower the new profile by the required cover depth. The downside of this method is that the copy of the profile is not dynamically linked to the first profile so if you update the profile the copy does not up date.
2. Use featureline. Most likely the as built services are surveyed as a 3dpolyline string or featureline’s you can make copy the featureline’s to a new site called offset and then rise of lower the new featureline the required cover.

Wednesday, 23 February 2011

Updating Old Textstyles to annotative Textstyles in xrefs

In working on projects that go on for a long period of time you will end up wanting to xref in some old services as builts into new design drawings. Depending on the age of these as built dwg’s they will probably not have text objects created with annotative textstyles.

If you have solid company standards and textstyle naming conventions that have been in use for same period of time you can just update your textstyles in your template to be annotative and then create a new standards file and run the checkstandards command to update all the old textstyles to be annotative.

If you do not have standard textstyles create some I typical have styles name txt2,txt3,txt5,txt7,txt9 where the number is the height of the text in paperspace in millimetres.
Now you have to update the text objects in the drawing manually to the correct annotative textstyles. To do this:-

1. Do a purge to purge all Textstyles not in use in the drawing.
2. Press Ctrl+2 to open design centre import the annotative Textstyles from your template file.
3. Determine the predominate scale in use on the drawings by looking at what scale the viewports are using in the drawing. Also check the viewport annotative scale is the same as the viewport scale.
4. Change the annotation scale to the predominate scale.
5. Select a text object press Ctrl+1 and look at the text height determine the height in paperspace

Height in Paperspace = Text Height   x 1000
6. Determine the Height in Paperspace 2mm = a Textstyle = Txt2 for example.
7. Right click choose “Select Similar” this will pick all the text objects of the same height and layer goto the properties window and change the textstyle to the correct Txt style.

Monday, 21 February 2011

Road Assembly Labelling Code Updated

Jeff Mishler has kindly updated my original code for Labelling Road Assemblies to 2011 and beyond and created a lsp version both are downloadable here
my original post can be found here
someone else has done a similar .net version here

Sunday, 20 February 2011

Join Alignments in Civil3d with Landxml

I am pretty sure that civil3d still does not have a join alignment command so to get round this when I want to join or break up some alignments I edit the landxml file that gets exported from Civil3d for example to join alignments.

1. Make sure the two alignments are drawn in the some direction
2. Go File->Export->Landxml and create one landxml file just containing the first alignment
3. Do the same again for the second alignment.
4. Goto the xml file of the second alignment to be joined to the first, right click on it and choose open with notepad. Note the length of the alignment
Highlight and copy all the lines of the geometry between the words <CoordGeom> and  <CoordGeom>
5. Go to the first landxml file and open it in notepad. Goto the second instance of <CoordGeom> insert a new line
above it and paste in the section of the landxml file copied in step 4.

6. Adjust the name of the alignment if you do not on the landxml import the alignment of the original name will be updated.
7. Add the length of the second alignment to the total length of the first alignment.
8. Do a file save as with a new name for the modified landxml file.
9. Go back to Civil3d and do a landxml import.
You should now see your joined alignment. I similar process can be used to break up alignments and remove pieces
you can also join, adjust profiles and transfer one profile from one alignment to another.

Friday, 11 February 2011

Open Windows Explorer in folder of currently open drawing

Alot of the time you are working a way on a drawing and someone wants something emailed from the current job folder you are in to them. To jump to that job file in explorer. Add the following code from this 
to a toolbar button so when you press it Windows Explorer is opened at the current drawing folder.

^C^C^P(STARTAPP (strcat "EXPLORER /e," (getvar "dwgprefix")))

1. Type CUI
2. Make a new custom command
3. Paste the code above into the command
4. Drag the command up to a toolbar you want it displayed on.

Thursday, 10 February 2011

Visual Basic (VB) for Civil3d

Over the last 3 or 4 years I have replied to various queries in forums on how to get started in programming for Civil3d. This was to help people get started as it is quiet hard to find an explanation in lay terms of how you go about things. So what follows below is an overview of my amateur understanding of the VB world and links to numerous references of further reading that I have found useful on the way to writing my own bits of time saving code for Autocad and Civil3d.
I am completely self taught so my descriptions of things will not be perfect for those more advanced programmers out there. But should be sufficient for those that want to start programming in Autocad Civil3d and get them heading in the right direction.
VBA and what is the difference?
For the benefit of those that have done some VBA programming before and others that want a bit of history there are two major differences in using VBA for Autocad versus

The Integrated Development Environment (IDE) ;the place you type your code for VBA is built-into Autocad and accessed by typing VBAIDE at the commandline and for is a standalone program run outside Autocad and can either be Microsoft Visual Basic Express Edition (Free) or Microsoft Visual Studio ($300US) or any other third party IDE you like.
The VBA (IDE) is being phased out of Autocad because it is old technology no longer being supported by Microsoft. As of 2010 Autodesk started to remove the VBA (IDE) from Autocad’s base install, it can however still be downloaded and installed separately, but for how much longer this will be an option no one knows.

If you are starting out from scratch or wanting to update some old VBA code to technology then you should start by using the IDE and not the VBA one. Seeing the VBA (IDE) was provided for free in Autocad and amateur programmers like myself like that model you will need to download and use Microsoft's free express programming interface. You will find other fulltime programmers use the professional version.

The way that the two IDE’s communicate with Autocad is different yet the same in places.Effectively the VBA (IDE) uses the ActiveX. .Com managed wrapper only while the (IDE) can use both the older .COM wrapper and the newer .NET wrapper. The benefit of the later being you can bring your old VBA code forward into the new IDE and type new code pretty much the same as you did before in VBA except with a few necessary modifications for the ThisDrawing object. 
Before I get into the basic setup you’ll need I should touch on the different programming languages. I tend to use the programming language Visual Basic (VB) as I started writing programs in Basic for my Commodore 64 as a kid and VB has sort of evolved from Basic. I have programmed in various languages over the years but as VB looks more like English and I program in spits and spurts, I always gravitate back to it because its easier to understand than say C# and C++. That said, it is pretty easy to pickup different programming languages once you're started in one as they use the same control statements like IF, FOR, NEXT and LOOP etc but just use different characters to represent them. to C# Examples
One of the much touted benefits of .net programming is that compiled dll files in different languages can be referenced by each other and used in one larger software solution. I have used this a number of times when i have seen something written in C# that I have wanted to use in my project. 
If you know nothing at all about programming you are going to have to learn how to use the programming environment IDE as well as the basics of the language you have chosen. Below under references, I have listed a number of good VB books that I have borrowed from the local library or brought on VBA and that I have found useful over the years. I have listed them in the order I would read them if I was starting out from scratch.

Get started
To get started on your machine you will have to
1.Download and install Microsoft Visual Basic .net Express edition either 2008 or 2010 on your PC from
2. Install a Autocad express template that lets you use the free express program by setting Autocad to load and open the .dll file you create when debugging your programs.
This is the trick to using the free Express IDE as by default the Express IDE does not give you access through its user interface to set Autocad as the program for use during debugging. To get round this Autodesk an others have created special template files that have this setting already made for you.
To date I have not found any specific Civil3d Templates for 2011 to 2009 however Strahimir Antoljak wrote one for 2008 for his AU paper which is downloadable here

There a number of basic Autocad templates available on the internet Autodesk have one in a wizard form downloadable from here
and Jerry Winters has another here that goes with his book here
I have not had much luck using the Autodesk template so I use Jerry’s. It would make the transition from VBA to a lot easier for everyone if Autodesk provided a base Civil3d Template.
3. Setup some additional references to a couple of special Civil3d .dll files that are so called managed wrappers.
Effectively I think of these files as the gateway into Autocad and Civil3d that VB Express has to use to see what commands,methods and properties that are available inside Autocad and Civil3d to be used. There are two types of references .COM ones and .NET ones. You do not have to reference all of the reference if you do not need them. But it pays to as generally you end up needing them as alot of the time with Civil3d you have to use the older .COM wrapper to work with certain objects that are not available in the .NET wrapper yet.

See the reference below to Joshua Modglin where here explains the references required for Civil3d 2010 on in a series of posts.

Upgrading old code.
For those not new to VB any programs that you have written in the VBA (IDE) in the past can be brought forward into
Stephen Preston has a good video on the process here.  If your programs are basic and do not include userform/dialog boxes or events the process is reasonably simple if not its a bit more involved.


Online help for Basic Autocad
Shipped help files with Civil3d


This link to the page where you can download the video DevTV: Introduction to AutoCAD .NET Programming I was talking about to give you a feel of what programming involves to get you started.
There have been a couple of good AU papers over the years that summarise getting started in for Civil3d. If you are an Autocad subscription member you get the benefit of access to the current years papers and presentations. If not you get access to the pervious years papers and before. As most good papers are repeated over a number of years you will generally find earlier versions of the same paper with free access.
Strahimir Antoljak wrote this paper for AU 2008 and I found it particularly helpful in explaining the whole VBA verse IDE it’s a bit old now with regards to the reference files you have to pull into the IDE but it gives you the intro and explains the Civil3d basics pretty well.
Strahimir had the same paper listed for AU2009 but did not attend and Jerry Winters stepped up last minute and presented a version of the paper which gives plenty of tips on general programming in and but does not cover the Civil3d basics of the 2008 paper that you should read first.

Autodesk Developer Centre
Joshua Modglin formally of Engineering Efficiency now wrote a number of posts on getting started in VB programming with Civil3d 2010 here
Jerry Winters Website, Book and any of his AU presentation are good value.


Chris’s blog has given great practical examples over the years on how to do thing in VB with Civil3d
Kean’s blog also gives good examples of now to do various things with Autocad mostly written in C# however
This book gives the basic introduction to vb
This book gives great tips on using Microsoft Visual Studio
Also this book is autocad specfic althrough VBA based good but better yet all the source code in the book for doing basic things in VBA is downloadable at this webpage 
This book gives a good overview of doing the general basics in and the programming environment.
Builds on the last book in a bit more depth.
Gives a good summary of programming in general especially good is the chapter on what classes are and the intro to structuring programs
Hope this helps you on the way to getting started in programming with
Related Posts Plugin for WordPress, Blogger...