Author Topic: Civil 3D | Parcels  (Read 39917 times)

0 Members and 1 Guest are viewing this topic.

BlackBox

  • King Gator
  • Posts: 3770
Civil 3D | Parcels
« on: August 22, 2012, 02:35:54 PM »
This is a new one for me...

Received a file that has 604 Parcels, all with the same number, and 0.00 Sq. Ft.. Selected them, and hit Delete, which shows that all were deleted at the command line... But they weren't.  :ugly:

So... How does one delete Parcels from a drawing?  :?

TIA
"How we think determines what we do, and what we do determines what we get."

BlackBox

  • King Gator
  • Posts: 3770
Re: Civil 3D | Parcels
« Reply #1 on: August 22, 2012, 02:39:45 PM »
... Forgot to mention, I'm using Civil 3D 2011.

Also, just took a peek at Object Browser in Visual Studio 2010, and Autodesk.Civil.Land.DatabaseServices.Parcel is a Public Sealed Class (inherited from the Entity Class); I'm still new to .NET, so does that protection level prevent me from even doing this programmatically (via CommandMethod)?
"How we think determines what we do, and what we do determines what we get."

mjfarrell

  • Seagull
  • Posts: 14444
  • Every Student their own Lesson
Re: Civil 3D | Parcels
« Reply #2 on: August 22, 2012, 02:48:19 PM »
This is in response to a request for the code. Written for C3D 2011. May need to change version.
Careful: this will remove ALL sites. The phantom parcels show up as "sites".

Dim AeccApp As AeccRoadwayApplication
Set AeccApp = ThisDrawing.Application.GetInterfaceObject("AeccXUiRoadway.AeccRoadwayApplication.8.0")
Dim si As AeccSite
Dim sis As AeccSites

Set sis = AeccApp.ActiveDocument.sites

For Each si In sis
sis.Remove (si.name)
Next
Be your Best


Michael Farrell
http://primeservicesglobal.com/

BlackBox

  • King Gator
  • Posts: 3770
Re: Civil 3D | Parcels
« Reply #3 on: August 22, 2012, 02:52:19 PM »
Just viewed the Parcel Class using IlSpy, and there are no Methods, Properties, etc. shown...

Just saw your post, Michael... I'll give that a try now. Thanks! :beer:

"How we think determines what we do, and what we do determines what we get."

BlackBox

  • King Gator
  • Posts: 3770
Re: Civil 3D | Parcels
« Reply #4 on: August 22, 2012, 03:48:00 PM »
Michael, you rock!  :mrgreen:

For anyone interested... This should support 2008-2013 (untested), but works well for 2011:

Code - Auto/Visual Lisp: [Select]
  1.  
  2. (defun c:AeccDeleteParcels (/ *error*)
  3.   (princ "\rAECCDELETEPARCELS ")
  4.  
  5.   (defun *error* (msg)
  6.     (if oSites
  7.       (vlax-release-object oSites)
  8.     )
  9.     (if aeccDoc
  10.       (vlax-release-object aeccDoc)
  11.     )
  12.     (if aeccApp
  13.       (vlax-release-object aeccApp)
  14.     )
  15.     (if acDoc
  16.       (vla-endundomark acDoc)
  17.     )
  18.     (cond ((not msg))                                                   ; Normal exit
  19.           ((member msg '("Function cancelled" "quit / exit abort")))    ; <esc> or (quit)
  20.           ((princ (strcat "\n** Error: " msg " ** ")))                  ; Fatal error, display it
  21.     )
  22.     (princ)
  23.   )
  24.  
  25.   ((lambda (acApp vrsn / option aeccApp aeccDoc oSites count acDoc)
  26.      (if
  27.        (and
  28.          (setq vrsn
  29.                 (cond
  30.                   ((vl-string-search "20.0" vrsn) "10.4")
  31.                   ((vl-string-search "19.1" vrsn) "10.3")
  32.                   ((vl-string-search "19.0" vrsn) "10.0")
  33.                   ((vl-string-search "18.2" vrsn) "9.0")
  34.                   ((vl-string-search "18.1" vrsn) "8.0")
  35.                   ((vl-string-search "18.0" vrsn) "7.0")
  36.                   ((vl-string-search "17.2" vrsn) "6.0")
  37.                   ((vl-string-search "17.1" vrsn) "5.0")
  38.                 )
  39.          )
  40.          (not (initget "All Select"))
  41.          (or (setq option
  42.                     (getkword "\nEnter an option [All/Select]<Select>: "
  43.                     )
  44.              )
  45.              (setq option "Select")
  46.          )
  47.          (ssget
  48.            (cond ((= option "Select") "_:L")
  49.                  ((= option "All") "_x")
  50.            )
  51.            '((0 . "AECC_PARCEL"))
  52.          )
  53.          (setq aeccApp (vla-getinterfaceobject
  54.                          acApp
  55.                          (strcat
  56.                            "AeccXUiLand.AeccApplication."
  57.                            vrsn
  58.                          )
  59.                        )
  60.          )
  61.          (setq aeccDoc (vlax-get aeccApp 'ActiveDocument))
  62.          (setq oSites (vlax-get aeccDoc 'sites))
  63.          (setq count 0)
  64.          (princ "\nWorking, please wait... ")
  65.          (princ)
  66.        )
  67.         (progn
  68.           (vla-startundomark
  69.             (setq acDoc (vla-get-activedocument acApp))
  70.           )
  71.           (vlax-for x (vla-get-activeselectionset acDoc)
  72.             (if
  73. ;;;           (and
  74.                 (vl-string-search "{" (vlax-get x 'displayname))
  75. ;;;             (not (vl-catch-all-error-p
  76. ;;;                    (vl-catch-all-apply
  77. ;;;                      'vlax-invoke
  78. ;;;                      (list oSites 'remove x)
  79. ;;;                    )
  80. ;;;                  )
  81. ;;;             )
  82. ;;;           )
  83.               (progn
  84.                 (vlax-invoke oSites 'remove x)
  85.                 (setq count (1+ count))
  86.               )
  87.             )
  88.           )
  89.           (foreach x (list (itoa count) " parcels removed. ")
  90.             (princ x)
  91.           )
  92.           (*error* nil)
  93.         )
  94.         (cond
  95.           (oSites (prompt "\nNo parcels found. ") (*error* nil))
  96.           (aeccDoc (*error* "Unable to access Sites"))
  97.           (aeccApp
  98.            (*error*
  99.              "Unable to access \"AeccXUiLand.AeccApplication.ActiveDocument\" Object"
  100.            )
  101.           )
  102.           (vrsn
  103.            (*error*
  104.              "Unable to create \"AeccXUiLand.AeccApplication\" Object"
  105.            )
  106.           )
  107.           ((*error* "Current version not supported"))
  108.         )
  109.      )
  110.    )
  111.     (getvar 'acadver)
  112.   )
  113. )
  114.  

If anyone tests a version that doesn't work, please let me know and I'll update the code accordingly.

Cheers! :beer:

** Edit - Looks like this code deletes Sites, and not just Parcels... I'll dig into this and post back when I find a solution. Code revised to check for Site vs. Parcel as both are "AeccDbFace"

** Edit - Code updated to allow for user to specify 'All' or 'Select' Parcels for deletion.

** Edit - Code updated to use 'AeccXUiLand.AeccApplication' in lieu of 'AeccXUiRoadway.AeccRoadwayApplication' Object.

** Edit - Code updated to support 2014, 2015; thanks Jeff!

** Edit - Appears that recent 2014 & 2015 SP updates have broken this routine, so I've revised the code to report the error, removing the vl-Catch-All-Apply call; for more information, see this post.
« Last Edit: November 25, 2014, 11:58:59 AM by BlackBox »
"How we think determines what we do, and what we do determines what we get."

BlackBox

  • King Gator
  • Posts: 3770
Re: Civil 3D | Parcels
« Reply #5 on: August 22, 2012, 04:48:15 PM »
Code revised in my previous post.

:: Summary ::

Originally there was an issue where the code would also delete all Sites, and not just Parcels. To the best of my knowledge, by checking for "{" in the Sites Collection Object's DisplayName Property, this will rule out a 'named' Site.

I suppose it's possible for a user to use "{" in their Site naming convention, but it is highly unlikely in my limited experience.

HTH
"How we think determines what we do, and what we do determines what we get."

BlackBox

  • King Gator
  • Posts: 3770
Re: Civil 3D | Parcels
« Reply #6 on: August 22, 2012, 05:19:27 PM »
Code revised here.

:: Summary ::

Changed command name from "AeccDeleteAllParcels" to "AeccDeleteParcels", and added user prompt to specify 'All' or 'Select' Parcels for deletion.
"How we think determines what we do, and what we do determines what we get."

Jeff_M

  • King Gator
  • Posts: 4086
  • C3D user & customizer
Re: Civil 3D | Parcels
« Reply #7 on: August 22, 2012, 05:19:53 PM »
Just an observation....when using the ActiveX API for C3D, you should try to keep the Application object limited to what you are doing. Parcels are a part of the Land library, so that is what should be accessed. This code works because (I think) the Roadway Application needs the Land Application so it gets loaded by default. But, by loading the Roadway Application, you introduce the overhead of having to load the Corridor objects unnecessarily. So replace "AeccXUiRoadway.AeccRoadwayApplication." with "AeccXUiLand.AeccApplication."

Just viewed the Parcel Class using IlSpy, and there are no Methods, Properties, etc. shown...
That's because there is not much in the way of Parcel support in the .NET API. But, as you've partially found, there are quite a number of properties and methods exposed via the COM API.

Jeff_M

  • King Gator
  • Posts: 4086
  • C3D user & customizer
Re: Civil 3D | Parcels
« Reply #8 on: August 22, 2012, 05:22:56 PM »
If you still have that drawing with all the odd parcels in it, could I have a look at it?

BlackBox

  • King Gator
  • Posts: 3770
Re: Civil 3D | Parcels
« Reply #9 on: August 22, 2012, 05:30:32 PM »
Just an observation....when using the ActiveX API for C3D, you should try to keep the Application object limited to what you are doing. Parcels are a part of the Land library, so that is what should be accessed. This code works because (I think) the Roadway Application needs the Land Application so it gets loaded by default. But, by loading the Roadway Application, you introduce the overhead of having to load the Corridor objects unnecessarily. So replace "AeccXUiRoadway.AeccRoadwayApplication." with "AeccXUiLand.AeccApplication."

Great point... Code revised (again) here.

Just viewed the Parcel Class using IlSpy, and there are no Methods, Properties, etc. shown...
That's because there is not much in the way of Parcel support in the .NET API. But, as you've partially found, there are quite a number of properties and methods exposed via the COM API.

I honestly do not even know all of the available COM Objects for Civil 3D... I think I stumbled across one of the API references (.chm) that listed .NET and COM Objects; just have to go find it again.

If you still have that drawing with all the odd parcels in it, could I have a look at it?

To avoid any issues with my work, I'd prefer not to post the drawing; email sent.
"How we think determines what we do, and what we do determines what we get."

Jeff_M

  • King Gator
  • Posts: 4086
  • C3D user & customizer
Re: Civil 3D | Parcels
« Reply #10 on: August 22, 2012, 05:51:52 PM »
You can find the COM reference material here:
C:\Program Files\Autodesk\AutoCAD Civil 3D 2011\Help\civil_api_activex_reference.chm

sdunn

  • Newt
  • Posts: 89
Re: Civil 3D | Parcels
« Reply #11 on: August 28, 2012, 09:50:29 AM »
Would there be any way to modify the code to delete the hidden parcels created by importing figures into a drawing?

                  AECC_PARCEL  Layer: "0"
                            Space: Model space
                   Handle = eede
              Site : {F313CE96-F5D7-4710-8A27A3DD777A4309}
              Name : {F313CE96-F5D7-4710-8A27A3DD777A4309}
      Parcel Style : _V-ByLayer-kha
  Area Label Style :


Perimeter: 0.00'     Area: 0.00 Sq. Ft.


                  AECC_PARCEL  Layer: "0"
                            Space: Model space
                   Handle = eeda
              Site : {EF82733B-9A10-47DC-87F033CD0FEB50AD}
              Name : {EF82733B-9A10-47DC-87F033CD0FEB50AD}
      Parcel Style : _V-ByLayer-kha
  Area Label Style :


Perimeter: 0.00'     Area: 0.00 Sq. Ft.

BlackBox

  • King Gator
  • Posts: 3770
Re: Civil 3D | Parcels
« Reply #12 on: August 28, 2012, 09:59:32 AM »
If I am understanding you correctly (and I could be wrong)... Wouldn't it be better to instead simply make it habit to actually 'name' your sites?  :?

... Then, only the parcels would have the braces "{*}" in the DisplayName Property. I am sure there's another Property (or Method?) that Parcels have available that Sites do not, that could be used to test for the Object type. Just haven't dug into it enough.

For a separate routine, I used ParcelLoops Property but that does not seem to work here if memory serves.
"How we think determines what we do, and what we do determines what we get."

Jeff_M

  • King Gator
  • Posts: 4086
  • C3D user & customizer
Re: Civil 3D | Parcels
« Reply #13 on: August 28, 2012, 11:25:19 AM »
Renderman, the Parcels which caused you to start this thread were likely created by Survey Figures during import. ONe of the links I gave you from years ago discusses these.

sdunn, I'm guessing that figures are like featurelines, as far as C3D sees them, so they must be on a site. This really seems to be a flaw in the design of C3D and I'm unaware of anything we can do about it.

sdunn

  • Newt
  • Posts: 89
Re: Civil 3D | Parcels
« Reply #14 on: August 28, 2012, 06:35:33 PM »
Jeff,
When figures are imported they default to the survey site.  The bug is that a large number of the hidden parcels are created when the figures are imported.  I originally thought that it was due to the figures enclosing an area and fulfilling the parcel requirements, but it also happens when figures do not intersect.  I have a drawing that only has two figures, but there are 4 hidden sites that are created.