Author Topic: Civil 3D | Parcels  (Read 40262 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: 4094
  • 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: 4094
  • 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: 4094
  • 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: 90
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: 4094
  • 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: 90
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.

BlackBox

  • King Gator
  • Posts: 3770
Re: Civil 3D | Parcels
« Reply #15 on: August 28, 2012, 06:54:29 PM »
Would it be logical then (conceptually speaking, as I'm on my iPhone), to employ a simple Command Reactor to 'cleanup' after import?

Unless the command is 'transparent' to the Reactor, monitoring the :vlr-CommandCancelled, :vlr-CommandEnded, and :vlr-CommandFailed Events should do the trick, methinks.
"How we think determines what we do, and what we do determines what we get."

jawbreaker31

  • Guest
Re: Civil 3D | Parcels
« Reply #16 on: July 16, 2014, 03:28:39 PM »
I guess I'm late to the Phantom Parcel party, but I would like for this to work in 2014.  Would it be possible to modify once more to add that into the lisp?  I tried on my end by adding ((vl-string-search "19.1" vrsn) "11.0") to the mix but that doesn't appear to do the trick. :-o

Thanks

Jeff_M

  • King Gator
  • Posts: 4094
  • C3D user & customizer
Re: Civil 3D | Parcels
« Reply #17 on: July 16, 2014, 03:56:11 PM »
adding ((vl-string-search "19.1" vrsn) "11.0") to the mix but that doesn't appear to do the trick.
For 2014 use "10.3", not "11.0". For 2015 this will be "10.4"

BlackBox

  • King Gator
  • Posts: 3770
Re: Civil 3D | Parcels
« Reply #18 on: July 16, 2014, 05:19:47 PM »
adding ((vl-string-search "19.1" vrsn) "11.0") to the mix but that doesn't appear to do the trick.
For 2014 use "10.3", not "11.0". For 2015 this will be "10.4"

Thanks Jeff - Code updated here (untested).

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

CADventurer

  • Guest
Re: Civil 3D | Parcels
« Reply #19 on: October 24, 2014, 10:03:19 AM »
I copied the latest code into an .lsp file and ran the command AECCDELETEPARCELS as indicated and selected ALL. but, it deleted 0 Parcels. Am I missing something?

Using 2014 SP2

BlackBox

  • King Gator
  • Posts: 3770
Re: Civil 3D | Parcels
« Reply #20 on: October 24, 2014, 10:17:07 AM »
... Am I missing something?

Not sure; do you have phantom parcels in your drawing?

If so, and the routine still doesn't work, try posting a drawing.
"How we think determines what we do, and what we do determines what we get."

TonyatAlpha

  • Guest
Re: Civil 3D | Parcels
« Reply #21 on: November 25, 2014, 11:00:02 AM »
I know this is a month late, but I've just found these "ghost" parcels in my template drawing file and would like to find a way to get rid of them.  I've tried using the lisp routine but it does not work.

Civil 3d 2014.  I have attached my template file. There are 1853 "ghost" parcels in the file.

should i just grab all my styles and settings and start with a fresh drawing.

any help would be greatly appreciated

mjfarrell

  • Seagull
  • Posts: 14444
  • Every Student their own Lesson
Re: Civil 3D | Parcels
« Reply #22 on: November 25, 2014, 11:25:10 AM »
I don't see any 'parcels' in either Site 1 or Survey Site, in this file attached.
Be your Best


Michael Farrell
http://primeservicesglobal.com/

mjfarrell

  • Seagull
  • Posts: 14444
  • Every Student their own Lesson
Re: Civil 3D | Parcels
« Reply #23 on: November 25, 2014, 11:25:53 AM »
I know this is a month late, but I've just found these "ghost" parcels in my template drawing file and would like to find a way to get rid of them.  I've tried using the lisp routine but it does not work.

Civil 3d 2014.  I have attached my template file. There are 1853 "ghost" parcels in the file.

should i just grab all my styles and settings and start with a fresh drawing.

any help would be greatly appreciated

what error message IF any do you get from the LISP file?
Be your Best


Michael Farrell
http://primeservicesglobal.com/

TonyatAlpha

  • Guest
Re: Civil 3D | Parcels
« Reply #24 on: November 25, 2014, 11:29:20 AM »
It just says it deleted 0 objects, I don't get any error popups or anything

AECCDELETEPARCELS
Enter an option [All/Select]<Select>: A

Working, please wait... 0 parcels removed.

Command:

mjfarrell

  • Seagull
  • Posts: 14444
  • Every Student their own Lesson
Re: Civil 3D | Parcels
« Reply #25 on: November 25, 2014, 11:45:41 AM »
...I see no ghosts...
Be your Best


Michael Farrell
http://primeservicesglobal.com/

BlackBox

  • King Gator
  • Posts: 3770
Re: Civil 3D | Parcels
« Reply #26 on: November 25, 2014, 11:51:40 AM »
Michael,

After an offline conversation, I was emailed a drawing with phantom parcels, where the user reported similar issue using 2014 SP2.

I've personally tested their drawing, using 2014 SP2 and can confirm the failure now being reported (a failure that I did not experience previously)... The vl-Catch-All-Apply call is precluding the following error from being reported, when the Remove() Method is invoked on the oSites Object:

Code: [Select]
Civil 3D API: The parameter is incorrect.

I've verified that the API allows for either Name (string), Object reference as parameter for the Remove() Method (and have tried both variations), yet the call throws an exception nonetheless.

I've been exploring a .NET alternative, but do not have anything more conclusive to add at this time.
"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 #27 on: November 25, 2014, 11:54:21 AM »
...I see no ghosts...

That's kind of the point... 1800+ Parcels selected with QSELECT Command, Select All option.
"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 #28 on: November 25, 2014, 11:55:02 AM »
let me test again...
Be your Best


Michael Farrell
http://primeservicesglobal.com/

mjfarrell

  • Seagull
  • Posts: 14444
  • Every Student their own Lesson
Re: Civil 3D | Parcels
« Reply #29 on: November 25, 2014, 12:00:55 PM »
hmm, sucks that now the fix for this break in the application is NOW broken thanks to whatever fix they (autodesk) affected in SP2
Be your Best


Michael Farrell
http://primeservicesglobal.com/

Jeff_M

  • King Gator
  • Posts: 4094
  • C3D user & customizer
Re: Civil 3D | Parcels
« Reply #30 on: November 25, 2014, 12:08:22 PM »
These phantom parcels are actually phantom sites. Most often created when importing Survey Figures. I have not found ANY way to remove them, be it lisp, .NET, hammer, prayer.

This has been an issue for years, not something that was just recently broken. The lisp that BB posted still does work in some cases, but not with these particular phantom objects.

mjfarrell

  • Seagull
  • Posts: 14444
  • Every Student their own Lesson
Re: Civil 3D | Parcels
« Reply #31 on: November 25, 2014, 12:09:37 PM »
so his best path is NEW file>>Import Settings and Styles and move forward.

Thanks for that JeffM and BB.
Be your Best


Michael Farrell
http://primeservicesglobal.com/

TonyatAlpha

  • Guest
Re: Civil 3D | Parcels
« Reply #32 on: November 25, 2014, 12:11:04 PM »
Thanks everyone, I was hoping it wouldn't come to that but I would rather do that than keep passing these objects to all our projects.

BlackBox

  • King Gator
  • Posts: 3770
Re: Civil 3D | Parcels
« Reply #33 on: November 25, 2014, 12:34:08 PM »
These phantom parcels are actually phantom sites. Most often created when importing Survey Figures. I have not found ANY way to remove them, be it lisp, .NET, hammer, prayer.

This has been an issue for years, not something that was just recently broken. The lisp that BB posted still does work in some cases, but not with these particular phantom objects.

The drawing I was sent offline actually does have phantom Parcels; you can select them, and apply a style that makes them display, but they cannot be Remove()-ed.  :| Grrr



Also worthy of note, is that both Sites and Parcels have an ObjectName of AcDbFace.

At least for the simplicity of some LISP sub-functions I have that can be used in concert with ODBX batch processing (for searching a directory of drawings for Sites, Parcels, etc. [I have others as well]), you can validate Sites by testing for an available Parcels Property (even if empty), whereas Parcels require testing the same AcDbFace for ParcelLoops Property availability.

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

cadhelp

  • Mosquito
  • Posts: 1
Re: Civil 3D | Parcels
« Reply #34 on: December 04, 2018, 06:40:34 PM »
I think I have figured it out. Reinserting same figures will disconnect old site and effectively make them "phantom". So all you need to do is to check the site area.

;;originated from
;;http://www.theswamp.org/index.php?topic=42585.msg477730#msg477730
;;by BlackBox
(defun c:AeccDeleteParcels ( / #ACAD# #ACADDOC# aeccDoc ss)
  (defun Civil-version ( / )
    (rtos(atof(vl-registry-read(strcat "HKEY_LOCAL_MACHINE\\"(vlax-user-product-key)) "Release"))2 1)
  )
  (defun Exitprompt ( msg / )(alert msg)(exit))
  (setq #ACAD# (vlax-get-acad-object))
  (setq #ACADDOC# (vla-get-activedocument #ACAD#))

  (setq ss(ssget "x" '((0 . "AECC_PARCEL"))))
  (if (not(setq aeccApp (vla-getInterfaceObject #ACAD# (strcat "AeccXUiLand.AeccApplication." (Civil-version)))))
    (exitprompt "Could not connect to AeccXUiLand.AeccApplication.")
  )
 
  (setq aeccDoc (vlax-get aeccApp 'ActiveDocument))
  (setq oSites (vlax-get aeccDoc 'sites))
  (vlax-for x (vla-get-activeselectionset #ACADDOC#)
    (if(=(vlax-get(vlax-get(vlax-get x 'Parcels)'Statistics)'Area)0)
       (vl-catch-all-apply 'vlax-invoke (list oSites 'remove x))
    )
  )
)


« Last Edit: December 04, 2018, 06:44:15 PM by cadhelp »