I can't seem to access the profile information i need. I need a routine to insert a block with an attribute in plan view along a centerline alignment displaying the profile elevation for that station along that alignment.
LISP if possible (may wish to modify for own needs in future). Willing to pay a little if working appropriately (using C3d 2011).
Sounds like you could do that with station labels. You could create a style that has a block and will desplay profile information of an attached profile. Then in the alignment labels dialog, set it to places at a set interval.
Glenn Pope Civil Designer/CAD Manager Green Civil Design
TGood point. All I really need is the ability to extract the coordinate of the origin point/insertion point of the label with the expression / reference, and the ability to extract the elevation so I can use them (this is important for quick grading, checks, etc.)
With blocks I'd do this via entget, etc, but not sure how to access the same info with styles. Anyone know?
bcinnv, can you give a few specifics of what you are doing? For instance, "ability to extract the elevation so I can use them", use them how? Visually? For use in other code you already have?
I ya... I need the elevation string for use in other code I already have in place. The coordinate of the insertion point for the label, also for use in other code.
If you are just looking to label the alignment with profile information then you should really look at the label styles are thare built into Civil 3D. If you are looking to do more than just label the alignment, then you should really look at something other than lisp to work in. The information that you are looking for is not stored in the dxf codes (entget) so LISP on its on is out.
If you really want to work with the Civil 3D data, I would suggest getting a copy of Microsoft VB.NET Express Edition (free download) and start working in VB.NET. Every bit of our API development work is on the .NET API. We do little with COM and nothing with LISP.
While you can do some great things with LISP it really is a non starter for Civil 3D.
Thanks Pete... that's what I needed to know... I was beatin' my head against the wall trying to figure out why I couldn't simply get the elevation and insertion point.
If you must use lisp to deal with existing lisp libraries like I have had to, this pretty much works. Insert real symbols for anything in <> as they are just descriptions.
get your alignment object and profile object how you would normally get a vla-object (easiest way is vlax-ename->vla-object)
But the best way for future proofing as Peter has mentioned, if its possible in your system, is to make a lisp-function in .net and set your input/output resbuffs as you require.
While this will work for any properties that are exposed to COM, we stopped writting the COM API a few releases ago so the access you'll have will be limited. All the new APIs are written in .NET.
Thanks... should head me in the direction I wanted to go. Thanks for the help! RE:.Net... I'll see... maybe someday. Unfortunately, it seems to me, there are no resources available for beginners wanting to learn .NET specifically for civil 3d. Everything I've seen, one has to have a decent understanding of .NET already.
...., there are no resources available for beginners wanting to learn .NET specifically for civil 3d. Everything I've seen, one has to have a decent understanding of .NET already.
Some real nice & helpful folks can be found at www.theswamp.org where there are .NET specific and "Land Lubber" forums.
And I am living proof you don't have to have a decent understanding of .NET already. 4 years ago I knew absolutely nothing about it. Now I know enough to not get so confused ... but I can write some meaningful and very powerful commands now that I couldn't even dream of doing in lisp (I came from lisp myself). I chose to go the C# route, as it is easier for me to look at vs the VB code, although they are similar enough you should get to the point that you can at least figure out what each is doing regardless of the one you choose to learn.
With the info provided earlier, and some code from a generous unknown author on http://cadpanacea.com I mixed up the following to snag the profile / alignment info I needed... it's pretty messy (as I just cut / paisted info I needed)... but its works with 2008 C3d...have to wait 'til tomorrow to test on 11 at work.
(defun c:test () (vl-load-com) (setq sel (entsel "\nSelect Alignment: ")) (setq sel2 (entsel "\nSelect Profile: ")) (setq ent (car sel)) (setq lst (entget ent)) (if (eq "AECC_ALIGNMENT" (cdr (assoc 0 lst))) (setq obj (vlax-ename->vla-object ent))) (setq ent2 (car sel2)) (setq lst2 (entget ent2)) (setq obj2 (vlax-ename->vla-object ent2)) (if obj (progn (setq nam (vlax-get-property obj 'Name)) (setq sta1 (vlax-get-property obj 'StartingStation)) (setq sta2 (vlax-get-property obj 'EndingStation)) (setq sta 100.0 off 10.0) (vlax-invoke-method obj 'PointLocation sta off 'x 'y) (entmake (list (cons 0 "POINT")(cons 10 (list x y)))) (setq pt1 (getpoint "\nSelect point: ")) (vlax-invoke-method obj 'StationOffset (car pt1) (cadr pt1) 'sta 'off) (setq elev (vlax-invoke-method obj2 "ElevationAt" sta)) (alert (strcat "The Elevation is " (rtos elev 2 2) "\nThe Station is " (rtos sta 2 2) "\nThe Offset is " (rtos off 2 2))) ) ) (princ));;;
There are two other sources for information that you may want to look into when the .Net day comes for you. For example, Autodesk now has a Civil 3D API blog.
Dog gone it! Sorry, Josh, I'd intended to include the Civil3D.com links but I, obviously, managed to leave them out. Guess I shouldn't be posting at, or near, bed time.
So I took your guys advice and dove into vb.net. It's not that difficult, for very basic stuff, such as "Hello World", and make a layer. But I'm finding it incredibaly complicated to come up with the station for an alignment via a point I pick on screen, and the profile elevation associated with it. Could you guys toss me a bone?
If you are able to get the alignment object and get the user picked point, then you can use the following method.
Dim sta As Double
Dim offs As Double
align.StationOffset(pickedPoint.X, pickedPoint.Y, Sta, offs)
The pickedPoint is what the user picked (a Point3D or Point2D object depending upon your needs).
The align object is the alignment object that you have gotten.
What is returned is through a referenced parameter (which is kind of weird way to work this but...). Thus the variable sta will contain the double representing the station of the picked point.
If you need help getting the alignment object or the picked point, just let us know.
--Disclaimer--
This obviously does not account for any adjustments to the northing/easting... 🙂
That's incredible... how easy you make that look. I have been way off track, and sadly yes, need help getting the point, and alignment. Believe for point it would be:
Dim pt As Object
pt = AcadDoc.Utility.GetPoint(, "Pick point:")
correct? Which would change "pickedPoint" in your code to pt.x, and pt.y?
Probably way off, but you won't believe how far off I've been.
I have a working example, but it's written in C#. I'm not sure it would help or confuse you even more. Before I post it, have you gone through any of the .NET Labs or ObjectARX dotnet code samples? Knowing how to work with Autocad documents, objects, etc., is extremely important to being able to use the Civil3D API's.
That's a negative. I can't seem to get past the "Hello World" and making layers, both of which, so far, I'd prefer to do in Autolisp (though running the .dll seems lightning fast). I look at the materails you guys posted but it's too far. Should I start with objectarx? Not sure where to go next.
My primary objective for even trying to pick up .net is simply to find or create a routine to list the station for the selected point, and the elevation of the profile associated with it, as noted, only because I'm afraid the vlisp solution I came up with might eventually become obsolete, or eventually not work (if it doesn't already).