AutoCAD Civil 3D General Discussion

AutoCAD Civil 3D General Discussion

Reply
Distinguished Contributor
charles.neely
Posts: 105
Registered: ‎12-14-2001
Message 1 of 11 (154 Views)
Accepted Solution

Select blocks by surface

154 Views, 10 Replies
07-09-2014 08:25 AM

I have a cut/fill volume surface with 2 ranges that leave a gap of 4 feet. I would like to select all tree blocks that are within the two ranges. Is this possible? Thanks, 

That was easier than I thought. Here's some LISP code that does what you're asking for:

 

;Select blocks within existing surface elevation analysis ranges
;copyright 2014, Timothy Corey
;Delta Engineering Systems
;Autodesk Authorized Value-Added Reseller
;Redding, CA
;permission is hereby granted to use this code for free.
;This code may not be sold or included in any for-sale software
;It is the responsibility of any person using this code
;to evaluate and test to be sure the code works for your needs.
;the program requests you select a representative block. All blocks of that name are added to a selection set.
;A surface selection is then requested.
;The program then creates a selection set of all blocks of the correct name and that fall within the
;elevation ranges of the elevation analysis applied to the surface.
;To use the selection set, select Previous.
(defun c:go ( / reptree blknam trees treesx surf **** zanal xreg cnt ctr itm minz maxz ctr1 len ob obz)
(vl-load-com)
(setq reptree (car (entsel "\nSelect representative tree block: ")))
(setq blknam (cdr (assoc 2 (entget reptree))))
(setq trees (ssget "x" (list (cons 2 blknam))))
(setq treesx (ssadd))
(setq surf (vlax-ename->vla-object (car (entsel "\nSelect Surface: ")))
**** (vlax-get-property surf 'SurfaceAnalysis)
zanal (vlax-get-property **** 'ElevationAnalysis)
zreg (vlax-get-property zanal 'ElevationRegions)
cnt (vlax-get-property zreg 'Count)
ctr 0)
(while (< ctr cnt)
(setq itm (vlax-get-property zreg 'item ctr))
(setq minz (vlax-get-property itm 'MinimumElevation)
maxz (vlax-get-property itm 'MaximumElevation)
)
(setq ctr1 0
len (sslength trees)
)
(while (< ctr1 len)
(setq ob (ssname trees ctr1))
(setq obz (cadddr (assoc 10 (entget ob))))
(if (and (<= obz maxz)(>= obz minz))
(ssadd ob treesx)
)
(setq ctr1 (1+ ctr1))
)
(setq ctr (1+ ctr))
)
(vl-cmdf "Select" treesx "")
(princ)
);end defun

 

Best regards,

 

Tim

*Expert Elite*
tcorey
Posts: 2,768
Registered: ‎12-18-2002
Message 2 of 11 (126 Views)

Re: Select blocks by surface

07-10-2014 10:15 AM in reply to: charles.neely

Do the tree blocks have elevations?

Tim Corey, Owner
Delta Engineering Systems
Redding, CA
Autodesk Authorized Value-Added Reseller
Distinguished Contributor
charles.neely
Posts: 105
Registered: ‎12-14-2001
Message 3 of 11 (125 Views)

Re: Select blocks by surface

07-10-2014 10:25 AM in reply to: tcorey

Yes, they do have elevations.

*Expert Elite*
tcorey
Posts: 2,768
Registered: ‎12-18-2002
Message 4 of 11 (122 Views)

Re: Select blocks by surface

07-10-2014 10:32 AM in reply to: charles.neely

Be patient. I might be able to have something for you by this afternoon....assuming the phone doesn't ring off the hook between now and then!

Tim Corey, Owner
Delta Engineering Systems
Redding, CA
Autodesk Authorized Value-Added Reseller
*Expert Elite*
tcorey
Posts: 2,768
Registered: ‎12-18-2002
Message 5 of 11 (113 Views)

Re: Select blocks by surface

07-10-2014 11:26 AM in reply to: charles.neely

That was easier than I thought. Here's some LISP code that does what you're asking for:

 

;Select blocks within existing surface elevation analysis ranges

;copyright 2014, Timothy Corey
;Delta Engineering Systems
;Autodesk Authorized Value-Added Reseller
;Redding, CA

;permission is hereby granted to use this code for free.
;This code may not be sold or included in any for-sale software

;It is the responsibility of any person using this code
;to evaluate and test to be sure the code works for your needs.

;the program requests you select a representative block. All blocks of that name are added to a selection set.
;A surface selection is then requested.
;The program then creates a selection set of all blocks of the correct name and that fall within the
;elevation ranges of the elevation analysis applied to the surface.
;To use the selection set, select Previous.


(defun c:go ( / reptree blknam trees treesx surf **** zanal xreg cnt ctr itm minz maxz ctr1 len ob obz)
  (vl-load-com)

  (setq reptree (car (entsel "\nSelect representative tree block: ")))
  (setq blknam (cdr (assoc 2 (entget reptree))))
  (setq trees (ssget "x" (list (cons 2 blknam))))
  (setq treesx (ssadd))

  

  (setq surf (vlax-ename->vla-object (car (entsel "\nSelect Surface: ")))
	**** (vlax-get-property surf 'SurfaceAnalysis)
	zanal (vlax-get-property **** 'ElevationAnalysis)
	zreg (vlax-get-property zanal 'ElevationRegions)
	cnt (vlax-get-property zreg 'Count)
	ctr 0)

  (while (< ctr cnt)

    (setq itm (vlax-get-property zreg 'item ctr))
    (setq minz (vlax-get-property itm 'MinimumElevation)
	  maxz (vlax-get-property itm 'MaximumElevation)
	  )

    (setq ctr1 0
	  len (sslength trees)
	  )

    (while (< ctr1 len)
      (setq ob (ssname trees ctr1))
      (setq obz (cadddr (assoc 10 (entget ob))))
      (if (and (<= obz maxz)(>= obz minz))
	(ssadd ob treesx)
	)
      (setq ctr1 (1+ ctr1))
      )
    (setq ctr (1+ ctr))
    )
  (vl-cmdf "Select" treesx "")
  (princ)
  );end defun

    

 

Best regards,

 

Tim

Tim Corey, Owner
Delta Engineering Systems
Redding, CA
Autodesk Authorized Value-Added Reseller
*Expert Elite*
jmayo
Posts: 3,030
Registered: ‎11-13-2006
Message 6 of 11 (113 Views)

Re: Select blocks by surface

07-10-2014 11:27 AM in reply to: charles.neely

Not that a lisp to automate this would not be better but I would bet a map query could do this.

 

I also think it could be as easy as going into a Front (or Back or Right or Left) view, draw a pline at the top and bottom of the elv range and simply select everyting in those ranges with a crossing window using the plines as a guide.

John Mayo, PE
IDSP 2014
Win 7 64, Xeon ES165@3.2Ghz,
64 GB RAM, Quadro K4000 (x2)
*Expert Elite*
tcorey
Posts: 2,768
Registered: ‎12-18-2002
Message 7 of 11 (106 Views)

Re: Select blocks by surface

07-10-2014 12:18 PM in reply to: tcorey

In my code, the auto-censor that Autodesk uses changed the variable I used that is short for Analysis. Unfortunately, I used the first four letters of that word and it got zapped for being potentially pornographic. Sorry about that.

 

Anywhere you see ****, just put in whatever you want, but be sure to use the same in all of those locations. If you want to go back to the first four letters of Analysis, that was what I originally used. Innocent mistake, sorry.

 

Good thing this is not a proctologists discussion group. They wouldn't be able to get anything done! ;-)

 

Tim

 

 

 

Tim Corey, Owner
Delta Engineering Systems
Redding, CA
Autodesk Authorized Value-Added Reseller
Distinguished Contributor
charles.neely
Posts: 105
Registered: ‎12-14-2001
Message 8 of 11 (102 Views)

Re: Select blocks by surface

07-10-2014 12:30 PM in reply to: tcorey

It was a great effort, but it didnt work. After trying it I realized my tree block is at the actual point elevation and my cut/fill surface is the difference between FG and EG.

*Expert Elite*
tcorey
Posts: 2,768
Registered: ‎12-18-2002
Message 9 of 11 (94 Views)

Re: Select blocks by surface

07-10-2014 01:00 PM in reply to: charles.neely
There is a surface tool that moves blocks to a surface elev. move the trees to the vol surf and run the routine again.
Tim Corey, Owner
Delta Engineering Systems
Redding, CA
Autodesk Authorized Value-Added Reseller
Valued Contributor
gunnarl
Posts: 63
Registered: ‎11-08-2006
Message 10 of 11 (91 Views)

Re: Select blocks by surface

07-10-2014 01:09 PM in reply to: charles.neely

I beleive you can accomplish this using the FILTER command. Add block name, and 2 elevation filters using <= or >= and the elevations of your blocks for each range. See attached image an an example. If your not familiar with the filter command Autocad help has some good info. Not as elegant as a lisp though...

 

 

Gunnar

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.