Saturday, 3 September 2011

VB.net code to find average height of PVI in Civil3d

I had an interesting question the other day from a colleague. Did I think you could find the average height of a profiles PVI with an expression? My immediate thought was no.
With a little bit of playing around my initial thought was confirmed.
This is because the general pitfall with labels, be it direct object labels or those nested in bands that use expressions, are that the content available for use in the label or expression are object specific and you only have access to that specific objects properties. (There are the odd exceptions to this but not many that jump to mind).
You should note, however, that the objects properties you do see in expressions are only a limited selection of those object properties that can be accessed with C# or VB .net.
Now, when I first saw expressions demonstrated in an early demo of Civil3d 2007, I thought these labels and expressions are great ! No more text updating. But then I thought, what if you could call VB.net sub routines from these labels/expressions to recalculate on the fly as well and update the label ? That would be awesome.  Alas, this is yet to eventuate.
Three wishes I have had for expressions for a while are:-
  1. As above vb.net routines could be called from expressions.
  2. That pipe expressions in bands could access all the properties of structures attached to them upstream and downstream.
  3. If statements should be able to return text answers like, if statements in Excel.
Anyway that is enough of a rant , let’s get on with some vb.net.  
This problem can be easily solved using VB.net, to do it I stitched together  a number of bits of code freely available on the web, as I am a bit rusty on coding at the moment having not done any since NZAU a couple of months ago. Here is the process I went though:-
First I had a look at the shipped samples to see if there was an example that worked with profiles to see how to access a profile information. I found one here: C:\Program Files\Autodesk\AutoCAD Civil 3D 2011\Sample\Civil 3D API\DotNet\VB.NET\ProfileSample\readme.txt
To get the example code up and running, to walk through the code refer to the process outlined in my earlier post here Now all of the shipped examples work by generating objects from programmed settings and not by selecting existing objects. That’s fine for shipped examples but in the real world we want to select an object in the drawing and work with it. To see how to do this, there is a good example available here posted by Joshua Modglin . It deals with selecting alignment objects so I downloaded the source code and modified it as highlighted below to select profiles only.
lcvtjjnn
Next, I added a sub routine code to output the calculated PVI average to the drawing as a text.  In line 55 of the code above reference is made to the routine “CreateText”. To create this routine I just took the code from the online developer help here and removed the imports highlighted below as we already have them in our class and do not need to double up.
sp2rcehu
Then I added the following lines of code to pass text to the sub routine and ask the user for the insertion point for the text.
3swpxgao
Once complete I tested the code by “netload” ing the test.dll and calling the new command “Profileaverage” . It worked as follows and you can download the source code here compiled for 2011 32bit.
Unable to display content. Adobe Flash is required.

Thursday, 25 August 2011

Old fashioned Linetypes with text, unreadable when given Lineweight

Been doing some water connection blowups, lately and I wanted to have a linetype with a thick lineweight in plan
and in the blowup viewport use the viewport layer lineweight override to have a lineweight a bit thinner.
But I came across an issue with our old style linetype that if you give them a lineweight the text becomes unreadable. So Googled the
problem and found these two helpful posts. Basically you have to create a linetype with the text as a true font type text object.
Note also make sure in your  .ctb file for the color that the use object lineweight is set to yes or the line will still appear thin on the print.
http://forums.autodesk.com/t5/AutoCAD-2007/Printing-lineweight-linetypes-text/td-p/1831207
http://thecadgeek.com/blog/2010/07/linetype-text/
image
Came across this two helpful posts that helped me fix the problem
image

Monday, 22 August 2011

Civil3d and Google Plus

Just got an invite to Google Plus so am having a play around with it and looking at doing some internal training with Manycam to showing my desktop though GooglePlus.

If you are into Civil3d and have not gotten an invite to GooglePlus and would like one.  Add a comment with your written email (i.e ralstogj at gmail.com) below and I will send you one of the 150 invites I have to give away and maybe we can setup a Civil3d hangout if your interested.

Sunday, 21 August 2011

Strange Pipe Style Behaviour

Just a reminder to myself when you have the current layer set to some thing other than 0 and use the pipe style with a line thickness set to 2.0mm
the colour of the line changes to what ever the color of the current layer not that in the style every strange.

Tuesday, 16 August 2011

Civil3d Points from Polyline Vertices

Reminder to myself again, this is where you go to make points from the vertices along a polyline
image
or if you want the points on a featureline
nh4japcy

Civil3d Profile Band Text Override (without exploding)

No matter how hard a programmer tries they will never create a program that satisfies everyone all of the time. However
if the software designer/programmer adds overrides to allow people to achieve what they want without taking a step backwards that is always appreciated.

I case in point is the “EditlabelText” command that was added in 2009 from memory. Just type the command and select the
band text you want to change or ctrl click the label and then release everything and press the right mouse button to
see the option in your shortcut menu. The second method only works for some text objects.

The command lets you override most band text with whatever you like without exploding the ProfileView. The one downside of the method is if you regenerate
the ProfileView the overrides are removed.
image

Thursday, 11 August 2011

Mtext Dynamic Columns

Reminder to myself this is where you find the mtext dynamic column insert in the ribbon
image
Related Posts Plugin for WordPress, Blogger...