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

0 Members and 1 Guest are viewing this topic.

BlackBox

  • Gator
  • Posts: 2853
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
"Potential has a shelf life." - Margaret Atwood

BlackBox

  • Gator
  • Posts: 2853
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)?
"Potential has a shelf life." - Margaret Atwood

mjfarrell

  • Seagull
  • Posts: 10527
  • 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

  • Gator
  • Posts: 2853
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:

"Potential has a shelf life." - Margaret Atwood

BlackBox

  • Gator
  • Posts: 2853
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 ss 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.         (setq ss
  48.                (ssget
  49.                  (cond ((= option "Select") "_:L")
  50.                        ((= option "All") "_x")
  51.                  )
  52.                  '((0 . "AECC_PARCEL"))
  53.                )
  54.         )
  55.         (setq aeccApp (vla-getinterfaceobject
  56.                         acApp
  57.                         (strcat
  58.                           "AeccXUiLand.AeccApplication."
  59.                           vrsn
  60.                         )
  61.                       )
  62.         )
  63.         (setq aeccDoc (vlax-get aeccApp 'ActiveDocument))
  64.         (setq oSites (vlax-get aeccDoc 'sites))
  65.         (setq count 0)
  66.         (princ "\nWorking, please wait... ")
  67.         (princ)
  68.       )
  69.        (progn
  70.          (vla-startundomark
  71.            (setq acDoc (vla-get-activedocument acApp))
  72.          )
  73.          (vlax-for x (setq ss (vla-get-activeselectionset acDoc))
  74.            (if (and (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.              (setq count (1+ count))
  84.            )
  85.          )
  86.          (vla-delete ss)
  87.          (foreach x (list (itoa count) " parcels removed. ")
  88.            (princ x)
  89.          )
  90.          (*error* nil)
  91.        )
  92.        (cond
  93.          (oSites (prompt "\nNo parcels found. ") (*error* nil))
  94.          (aeccDoc (*error* "Unable to access Sites"))
  95.          (aeccApp
  96.           (*error*
  97.             "Unable to access \"AeccXUiLand.AeccApplication.ActiveDocument\" Object"
  98.           )
  99.          )
  100.          (vrsn
  101.           (*error*
  102.             "Unable to create \"AeccXUiLand.AeccApplication\" Object"
  103.           )
  104.          )
  105.          ((*error* "Current version not supported"))
  106.        )
  107.     )
  108.   )
  109.    (getvar 'acadver)
  110.  )
  111. )
  112.  

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!
« Last Edit: July 16, 2014, 05:19:12 pm by BlackBox »
"Potential has a shelf life." - Margaret Atwood

BlackBox

  • Gator
  • Posts: 2853
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
"Potential has a shelf life." - Margaret Atwood

BlackBox

  • Gator
  • Posts: 2853
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.
"Potential has a shelf life." - Margaret Atwood

Jeff_M

  • King Gator
  • Posts: 3527
  • 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: 3527
  • 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

  • Gator
  • Posts: 2853
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.
"Potential has a shelf life." - Margaret Atwood

Jeff_M

  • King Gator
  • Posts: 3527
  • 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: 46
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

  • Gator
  • Posts: 2853
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.
"Potential has a shelf life." - Margaret Atwood

Jeff_M

  • King Gator
  • Posts: 3527
  • 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: 46
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.