Jump to content

Add Points to TIN Surface


BlackBox

Recommended Posts

How does one add a point object (x y z), to a vl-* surface object?

 

Here is what I have attempted already (unsuccessfully):

 

(vlax-invoke-method
 (vlax-get (vlax-get exist_aecSurfItem 'inputs) 'pointfiles)
 'add
 [color=seagreen];; What goes here... Safearray, variant, or something else?[/color]
 )

 

 

Sort of like using the _AECTREEMGREVENT command, without Terrain Model Explorer.

 

I cannot find anything useful in apropos (or don't know what to look for!)... any help would be greatly appreciated.

Edited by BlackBox
Link to comment
Share on other sites

The support files have a number of examples of code for vba lisp etc these include an example to create points and make a surface there located somewhere like \program files\autodesk\civil 3d 2011\sample. Just had a look there definately in 2009 version maybe not 2011 anymore.

 

Opening up the aecc database is complicated. Working on something at moment that manipulates the points and surfaces. Let me know here if you can not find example code.

Link to comment
Share on other sites

Thanks for the pointer, Bigal.

 

I found the sample(s) here:

.\Program Files\\Sample\Civil 3D API\Vba\

 

I should have made it clear in my OP that I am using AutoCAD Civil 3D Land Desktop Companion 2009. I'm not sure if I have access to the C3D API, from LDC..?

 

Basically, I am selecting a polyline and providing an elevation, with which to create a flat TIN surface for Floodplain calcs against the existing ground surface.

 

(Maybe this will help you?) Here's how I have accessed the surfaces collection:

 

(vl-load-com)
 ;; Version test
 (cond
   ((vl-string-search "R16.2" *vrsn*) (setq appstr "4"))               ; 2006
   ((vl-string-search "R17.2" *vrsn*) (setq appstr "8"))               ; 2009
   (t (alert "This version of LDT not supported!")))
 ;; Set current surface
 (prompt
   "\n  >>  Select Existing Surface for Floodplain Calculations: ")
 (dt_mnl)
 (zz_sdsk '(dt_srfopen))
 (c:LDD)
 ;; Main code
 ;|  Thanks to Jeff Mishler,
 [url]http://forums.autodesk.com/t5/AutoCAD-Land-Desktop/Label-Surface-Spot-Elevation/m-p/2422911[/url] |;
 (if
   (and (setq aeccApp
               (vla-getInterfaceObject
                 *acadDoc*
                 (strcat "Aecc.Application." appstr)))
        (setq aeccDoc (vla-get-activedocument aeccApp))
        (setq aeccUtil (vlax-get aeccDoc "utility"))
        (setq aeccProj (vlax-get aeccApp 'activeProject))
        (setq aecSurfs (vlax-get aeccProj "Surfaces"))
        (setq exist_aecSurfName (vlax-get aecSurfs "Currentsurface"))
        (setq exist_aecSurfItem (vla-item aecSurfs exist_aecSurfName)))
 ;; ...Code
 )

 

 

Here is how I've added a new (empty) surface:

 

      (setq new_aecSurfItem (vla-add aecSurfs "TEST"))
      (vlax-put new_aecSurfItem "Currentsurface" "TEST")
      (vla-put-description
        new_aecSurfItem
        "This is a Test, for My Floodplain Calculation Routine. ")

 

 

Now... Tackling one hurdle at a time... I need to add the surface points to the new (empty) surface.

 

[color=red];; Missing code[/color]

 

 

 

Note - I am still trying to determine if it is best to add four points via the bounding box (i.e., larger than my polyline) and then use a copy of the polyline as a border, *OR* if I should instead, step through all of the vertexes of the polyline, adding a surface point.

 

Again, adding point entities to model space is the easy part... I need help determining how to best add those points to the surface (so I can build it).

 

Edit: Then, use this code to build the surface (tested successfully):

 

(vlax-invoke-method new_aecSurfItem 'build) 

 

 

... Later I will have to figure out how to conduct the floodplain calcs. I am simply trying to 'automate' a process which is long, and takes up a lot of project budget. As VBA can do these tasks (and VBA uses the ActiveX COM API), I am *hoping* that Visual LISP can do the same.

Edited by BlackBox
Link to comment
Share on other sites

I've successfully created a points file in the ../Dtm/ directory, which allows me to build the surface! (Hooray!!!)

 

However, I need to add a surface boundary, and I am missing the proper syntax, or arguments. This is the method I have been experimenting with (unsuccessfully):

 

;; Add boundary to surface
      (vlax-invoke-method
        (vlax-get (vlax-get new_aecSurfItem 'inputs) 'boundaries)
        'add
        [color=seagreen];| (vlax-safearray->list[/color]
[color=seagreen]          (vlax-variant-value[/color]
[color=seagreen]            (vla-get-coordinates[/color]
[color=seagreen]              (vlax-ename->vla-object eName)))) |;[/color]
        (vlax-ename->vla-object eName)
        [color=seagreen];;eName[/color]
        "Boundary0"
        "Outer"
        "Yes"
        )

 

 

This is the error message I get, in the current configuration:

 

lisp value has no coercion to VARIANT with this type:  #<VLA-OBJECT 
IAcadLWPolyline 224bcb04>

 

 

When done manually (i.e., right+click on the boundaries node within Terrain Model Explorer, select Add Boundary Definition), this is a copy of the command line:

 

Command: _AECTREEMGREVENT
Select polyline for boundary:
Boundary name <[color=navy]Boundary0[/color]>:
Boundary type (Show/Hide/Outer) <[color=navy]Outer[/color]>:
Make breaklines along edges? (Yes/No) <[color=navy]Yes[/color]>:
Select polyline for boundary:

 

 

What am I missing!?

Edited by BlackBox
Typo
Link to comment
Share on other sites

RK was kind enough to provide me the solution (copied here):

 

Check your syntax.

The HELP file says...

 

RetVal = object.Add(Type, bIsBreakLine, Coordinates[, Description])

 

So the arguments to the 'Add method should be something like

 

0
:vlax-true
(vlax-get-property (vlax-ename->vla-object eName) "Coordinates")
"Boundary0"

 

 

Source: http://forums.augi.com/showthread.php?p=1099004#post1099004

 

 

Thanks, RK!

 

Edit: Now to figure out how to process a Floodplain calculation programmatically!

Link to comment
Share on other sites

I think it would be easier just to continue using the compare two surfaces for a volume answer rather than spending lots of time writing a volume routine.

 

If you want to though if you research into "land surveying" you will find the mathmatical method for calculating surface volumes.

Link to comment
Share on other sites

I appreciate the feedback, Bigal. I somewhat agree; I am not trying to re-invent the wheel, but rather automate a *long* production process (as much as possible).

 

I doubt I will produce an all inclusive routine for the moment, but being able to quickly create surfaces with one click helps tremendously... I have a roadway project with several dozens of basins to compare volumes (i.e., each basin is at a different floodplain elevation), and produce exhibits for.

 

At *minimum*, this capability saves me days of work, and will easily save our junior Tech's a week, if not more (Hooray efficiency!).

Link to comment
Share on other sites

Save you looking up the next versions

 

((vl-string-search "R17.2" vrsn) (setq appstr "6.0")) ;09

((vl-string-search "R18.0" vrsn) (setq appstr "7.0")) ;10

((vl-string-search "R18.1" vrsn) (setq appstr "8.0")) ;11

Link to comment
Share on other sites

((vl-string-search "R17.2" *vrsn*) (setq appstr "[color=red]8[/color]")) ; 2009

 

((vl-string-search "R17.2" vrsn) (setq appstr "[color=red]6.0[/color]")) ;09
((vl-string-search "R18.0" vrsn) (setq appstr "7.0")) ;10
((vl-string-search "R18.1" vrsn) (setq appstr "8.0")) ;11

 

 

Err...?!? :?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...