Community
Civil 3D Customization
Welcome to Autodesk’s AutoCAD Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Update Code - Extract All Surface Boundaries

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
neilyj666
703 Views, 7 Replies

Update Code - Extract All Surface Boundaries

The code supplied by Andrew in this thread http://forums.autodesk.com/t5/autocad-civil-3d-customization/code-to-extract-all-surface-boundaries/... worked great in 2014 but not in 2015.

 

I get the following message and then Civil crashes....:(

 

Cannot Get Objects.jpg

 

Does anyone have time to take a look at the source code and tweak for 2015 please?

 

Many thanks

 

Neil

neilyj (No connection with Autodesk other than using the products in the real world)
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


AEC Collection 2024 UKIE (mainly Civil 3D UKIE and IW)
Win 11 Pro x64, 1Tb Primary SSD, 1Tb Secondary SSD
64Gb RAM Intel(R) Xeon(R) W-11855M CPU @ 3.2GHz
NVIDIA RTX A5000 16Gb, Dual 27" Monitor, Dell Inspiron 7760
7 REPLIES 7
Message 2 of 8
Jeff_M
in reply to: neilyj666

Neil, I rewrote the code in lisp so it can be used in any version released to date (at least since the ability to extract the boundaries was added).

 

(defun c:extractallsurfaceboundaries (/ c3d c3ddoc surfs)
  (if (setq C3D (strcat "HKEY_LOCAL_MACHINE\\" (if vlax-user-product-key (vlax-user-product-key) (vlax-product-key) ) )
      C3D (vl-registry-read C3D "Release")
      C3D (substr C3D 1 (vl-string-search "." C3D (+ (vl-string-search "." C3D) 1) ) )
      C3D (vla-getinterfaceobject *acad* (strcat "AeccXUiLand.AeccApplication." C3D) )
      )
    (progn
      (setq c3ddoc (vlax-get c3d 'activedocument)
	    surfs (vlax-get c3ddoc 'surfaces)
	    )
      (vlax-for surf surfs
	(vlax-invoke surf 'extractborder 1)
	)
      (vlax-release-object c3d)
      )
    )
  (princ)
  )

 Just copy the code to a blank text document and save it as a .lsp file (or add it directly to your acaddoc.lsp).

Jeff_M, also a frequent Swamper
EESignature
Message 3 of 8
neilyj666
in reply to: Jeff_M

Thanks Jeff - but it crashed when I tried to run it......:(

 

Crash.jpg

neilyj (No connection with Autodesk other than using the products in the real world)
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


AEC Collection 2024 UKIE (mainly Civil 3D UKIE and IW)
Win 11 Pro x64, 1Tb Primary SSD, 1Tb Secondary SSD
64Gb RAM Intel(R) Xeon(R) W-11855M CPU @ 3.2GHz
NVIDIA RTX A5000 16Gb, Dual 27" Monitor, Dell Inspiron 7760
Message 4 of 8
Jeff_M
in reply to: neilyj666

Add this line as the second line in the lisp:
(vl-load-com)
Jeff_M, also a frequent Swamper
EESignature
Message 5 of 8
neilyj666
in reply to: Jeff_M

Still the same error message.....

 

ErrorStill.jpg

neilyj (No connection with Autodesk other than using the products in the real world)
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


AEC Collection 2024 UKIE (mainly Civil 3D UKIE and IW)
Win 11 Pro x64, 1Tb Primary SSD, 1Tb Secondary SSD
64Gb RAM Intel(R) Xeon(R) W-11855M CPU @ 3.2GHz
NVIDIA RTX A5000 16Gb, Dual 27" Monitor, Dell Inspiron 7760
Message 6 of 8
tyronebk
in reply to: neilyj666

Jeff just forgot to acquire the ACAD object. Replace *acad* with (vlax-get-acad-object) and it should work as expected.

 

Edit: Actually, here's the modified code so that people don't have to parse the entire thread to get it working.

(defun c:extractallsurfaceboundaries( / c3d c3ddoc surfs *acad* )
	(if (setq *acad* (vlax-get-acad-object)
		c3d (strcat "HKEY_LOCAL_MACHINE\\" (if vlax-user-product-key (vlax-user-product-key) (vlax-product-key) ) )
		c3d (vl-registry-read c3d "Release")
		c3d (substr c3d 1 (vl-string-search "." c3d (+ (vl-string-search "." c3d) 1) ) )
		c3d (vla-getinterfaceobject *acad* (strcat "AeccXUiLand.AeccApplication." c3d) )
		)
		(progn
			(setq c3ddoc (vlax-get c3d 'activedocument)
				surfs (vlax-get c3ddoc 'surfaces)
			)
			(vlax-for surf surfs
				(vlax-invoke surf 'extractborder 1)
			)
			(if (not (vlax-object-released-p c3d) ) (vlax-release-object c3d) )
			(if (not (vlax-object-released-p *acad*) ) (vlax-release-object *acad*) )
		)
	)
	(princ)
)
(vl-load-com)

 

Message 7 of 8
Jeff_M
in reply to: tyronebk

Thanks, Tyrone. I have had that variable set in my acaddoc.lsp for so long I forget that it's not a native variable. 😞
Jeff_M, also a frequent Swamper
EESignature
Message 8 of 8
neilyj666
in reply to: Jeff_M

Thanks Jeff and Tyrone - works like a charm now....:)

neilyj (No connection with Autodesk other than using the products in the real world)
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


AEC Collection 2024 UKIE (mainly Civil 3D UKIE and IW)
Win 11 Pro x64, 1Tb Primary SSD, 1Tb Secondary SSD
64Gb RAM Intel(R) Xeon(R) W-11855M CPU @ 3.2GHz
NVIDIA RTX A5000 16Gb, Dual 27" Monitor, Dell Inspiron 7760

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


 

Autodesk Design & Make Report