Civil 3D Export Points Properties via Lisp

Civil 3D Export Points Properties via Lisp

CodeDing
Advisor Advisor
2,624 Views
20 Replies
Message 1 of 21

Civil 3D Export Points Properties via Lisp

CodeDing
Advisor
Advisor

Hey there,

 

I've spent way too much time trying to figure this out today with no luck.

Does anybody know how I can control these 4 properties (marked via arrows) on the "Export Points" command via AutoLISP or Visual Lisp?

I'm using Civil 3D 2019.

 

image.png

Best,

~DD

0 Likes
Accepted solutions (1)
2,625 Views
20 Replies
Replies (20)
Message 2 of 21

john.uhden
Mentor
Mentor

Offhand, I don't know, but what's wrong with the export mechanism they give you?

Though having been around AutoCAD and Land Desktop forever, and writing my own routines to do what I want, my better educated associate at work keeps reminding me that there are a bundle of built-in ways to do what I want.  Of course I can't help disagreeing with him and keep writing my own, which I naturally think are better.

The guy who would probably know is Jeff Mischler, who spends most of his time in the C3D Customization forum.  I used to teach him a lot years ago, and now he teaches me.  Best of luck!

John F. Uhden

0 Likes
Message 3 of 21

CodeDing
Advisor
Advisor

@john.uhden wrote:

..my better educated associate at work keeps reminding me that there are a bundle of built-in ways to do what I want..


Civil 3D has an AMAZING amount of built-in tools which are great (and probably save us a bunch of customization time). We should be using them to their fullest extent... but that also shouldn't deter us from exploring our capabilities 😉

 


@john.uhden wrote:

..but what's wrong with the export mechanism they give you?


The mechanism, to my knowledge, cannot be used consistently as a part of a routine. If I run a command with multiple steps, and an export being involved in that process, I can't have the routine pausing for user-input mid way through.. And even if I CAN use the "-EXPORTPOINTS" as part of a (command ...) call, how will I know that no elevation adjustments are being made? or transformations? I need to know how to control those 4 items.

 

Btw, I switched to using Civil 3D last month since I up and moved states / companies. Glad to be working with such a highly capable program with more features built-in than vanilla acad. It's good to stretch to have so many abilities at your fingertips. So looks like you & I will be going through the C3D customizations together. Might have to bounce some ideas back and forth one day.

 

EDIT:

And for those curious, yes I AM aware that I can just grab the Points Collection via Visual Lisp or a Point Group, then just loop through points extracting data and creating a CSV as I choose.. but there is a built-in method for exporting points via Visual Lisp, and I would prefer to use the built-in features as much as possible before creating a custom export function.

 

Best,

~DD

0 Likes
Message 4 of 21

Sea-Haven
Mentor
Mentor

It is possible to get at the points in CIV3D, done a bit of stuff pretty sure the point group holds the point numbers not the points, so that solves 1st step. Will see what I have. 

 

Elev adjust do you just want simple +/- to Z ?

 

Co-ordinate adjust that is beyond me when it comes to UTM zones etc. As I have never done data expansion not sure. 

Do you want pick a point or enter name or  select group name from pop up dcl list, I have that. Just did XYZ as there is a wealth of info on a cogo point.

 

 

(defun c:test ( / vrsn appstr aecapp aeccdoc opoints grp x pts lst ptid)

(setq vrsn (vlax-product-key))
(cond
((vl-string-search "R17.2" vrsn) (setq appstr "6.0")) ;09
((vl-string-search "R18.0" vrsn) (setq appstr "7.0")) ;2010
((vl-string-search "R18.1" vrsn) (setq appstr "8.0")) ;2011
((vl-string-search "R18.2" vrsn) (setq appstr "9.0")) ;2012 
((vl-string-search "R19.0" vrsn) (setq appstr "10.0")) ;2013 
((vl-string-search "R19.1" vrsn)(setq appstr "10.3"));;2014
((vl-string-search "R20.0" vrsn)(setq appstr "10.4"));;2015
((vl-string-search "R20.1" vrsn)(setq appstr "10.5"));;2016     
((vl-string-search "R21.0" vrsn)(setq appstr "11.0"));;2017  
((vl-string-search "R22.0" vrsn)(setq appstr "12.0"));;2018   
((vl-string-search "R23.0" vrsn)(setq appstr "13.0"));;2019
((vl-string-search "R23.1" vrsn)(setq appstr "13.2"));;2020
((alert "This version of C3D not supported!"))
)

(setq aeccApp (vla-getinterfaceobject (vlax-get-acad-object) (strcat "AeccXUiLand.AeccApplication." appstr)))
(setq aeccDoc (vlax-get-property aeccApp "ActiveDocument"))

(setq oPoints (vlax-get-property aeccDoc "Points"))
(setq  grp (vlax-get-property aeccDoc "Pointgroups"))


(setq grpname (getstring "\nEnter pt group name"))

(vlax-for gname grp
  (if (= (vla-get-name gname) Grpname)
  (setq pts (vlax-get gname 'points))
  )
)

(setq pts (vl-sort pts '<))

(setq lst '())
(repeat (setq x (length pts))
  (setq ptnum (nth (setq x (- x 1)) pts))
  (vlax-for ptid opoints
    (if (= (vlax-get ptid 'Number) ptnum)
      (setq lst (cons (list  (vlax-get ptid 'Easting) (vlax-get ptid 'Northing) (vlax-get ptid 'Elevation)) lst))
    )
  )
)

(princ lst)
(alert "Now have a list of xyz ")

(princ)
)

(c:test)

 

 

0 Likes
Message 5 of 21

Sea-Haven
Mentor
Mentor

I have some other CIV3d stuff the best one being using toolbars to control your surface displays, just found having to open toolspace all the time was a pain, so pick icon 0.5 and contours turn on, multiple surfaces will ask which one to apply to, "no display", rain drops, triangles etc just pick.

 

Import / modify description key sets.

 

send a request to info@alanh.com.au will provide more info on what I have for CIV3D

0 Likes
Message 6 of 21

john.uhden
Mentor
Mentor

@Sea-Haven 

Ah.  That's the kinda stuff that makes me bloodthirsty.

I used to do all that kinda stuff with LDD.

BTW, I have a pair of range<->list conversion functions if you ever need them.

John F. Uhden

0 Likes
Message 7 of 21

Sea-Haven
Mentor
Mentor

Its just stuff like the field survey is imported and the telephone pits are at wrong angle in some parts of the survey so enter a angle then pick pick pick etc. Can do with properties also. I know set angle in field code but when doing 10,000 points surveys its an overhead. Our surveyors would fix a lot of this before we got at it for road design.

 

Have a dynamic block, tree trunk and spread, reads code tr3*3 = tree 3m dia 300mm trunk. Yes there is other software that does it as well.

0 Likes
Message 8 of 21

john.uhden
Mentor
Mentor
There's always a lot of dogwork that's just hard to avoid. Gotta budget
for it, and then train the cheapest tech you've got to do it well and fast.

John F. Uhden

0 Likes
Message 9 of 21

CodeDing
Advisor
Advisor

@Sea-Haven ,

 

Thank you for the alternate solution. I was aware that this is possible, and I already have the code available for such utilities, but I'm trying to stick to my original request as much as possible.

 

So, I am still left curious if there is an AutoLISP option that anybody knows of to control those 4 properties shown in original image?

 

Best,

~DD

0 Likes
Message 10 of 21

john.uhden
Mentor
Mentor

I took a look at the C3D2020 help, but I couldn't find any additional clues on how to control the additional options.

Then I thought maybe they are hidden in the registry.  I'm not gonna do it, but maybe you can export your registry profile, perform the C3D EXPORT with options changed, export the registry profile again and compare the before and after for any differences.  ZTREE is capable of highlighting differences with its File Compare option.  Maybe you have other software that can do that, but if not I'm willing to take your files and run a compare on them for you.  After all, this is stuff we hackers just HAVE TO know about.

Then again, have you asked @Jeff_M (Jeff Mischler) if he has the Rosetta Stone on this one?

John F. Uhden

Message 11 of 21

Sea-Haven
Mentor
Mentor

Tried exportpoints a couple of times the only remember is the point type PENZ etc all the other info is not remembered, so not sure how much the reigister may hold.

0 Likes
Message 12 of 21

Jeff_M
Consultant
Consultant
Accepted solution

@john.uhden thanks for tagging me to see this. (FYI, no c in Mishler 🙂 )

@CodeDing here is an example showing how to use the C3D COM API to do the points exporting.

(defun c:exportpointstofile( / C3DAPP C3DDOC DATASTR EXPORTOPTIONS POINTS)
  (defun getaeccApp (module / *acad* C3D) ;; module must be "Land", "Pipe", "Roadway", or "Survey"
  (vl-load-com)
  (if (and (setq *acad* (vlax-get-acad-object))
	   (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)
		       )
		     )
		 C3Dapp (vla-getinterfaceobject
		       (vlax-get-acad-object)
		       (strcat "AeccXUi" module ".Aecc" (if (= (strcase module) "LAND") "" module) "Application." C3D)
		     )
                 ;;the next 2 lines added for the exportoptions
		 datastr (strcat "AeccXLand.AeccTinCreationData." C3D)
		 exportoptions (vla-getinterfaceobject (vlax-get-acad-object) (strcat "AeccXLand.AeccPointExportOptions." C3D))
	   )
      )
    C3Dapp
  )
)
  (setq c3dapp (getaeccapp "Land")
	c3ddoc (vlax-get c3dapp 'activedocument)
	points (vlax-get c3ddoc 'points)
	)
  (vlax-put exportoptions 'adjustelevation :vlax-true)
  (vlax-put exportoptions 'expandcoordinatedata :vlax-false)
  (vlax-put exportoptions 'usepointgroup :vlax-true)
  (vlax-put exportoptions 'pointgroup "Trees")
  (vlax-put exportoptions transformcoordinate :vlax-false)
  (vlax-invoke points 'exportpoints "D:\\mypointfileexport.csv" "PENZD (comma delimited)" exportoptions)
  (vlax-release-object exportoptions)
  (vlax-release-object c3dapp)
  (princ)
  )

 

Jeff_M, also a frequent Swamper
EESignature
Message 13 of 21

john.uhden
Mentor
Mentor
@Sea-Haven
Bummer. If the options aren't saved anywhere as subsequent defaults, and
if there is no command-line version, then our Code comrade is rather
stuck. That vaccuums.
Can we file a class action for at least a command-line version?

John F. Uhden

0 Likes
Message 14 of 21

john.uhden
Mentor
Mentor
My apologies for the Germanic/Nordic/whatever misspelling.
I kinda knew you would come to the rescue, if prompted.
I think we oughta keep you around for a while. You're too good a student.
🙂

John F. Uhden

0 Likes
Message 15 of 21

CodeDing
Advisor
Advisor

@Jeff_M ,

 

I won't be able to test until tomorrow, but these were exactly what I was looking for:

(setq exportoptions
        (vla-getinterfaceobject
          (vlax-get-acad-object)
          (strcat "AeccXLand.AeccPointExportOptions." C3D)
        )
)
(vlax-put exportoptions 'adjustelevation :vlax-true)
(vlax-put exportoptions 'expandcoordinatedata :vlax-false)
(vlax-put exportoptions 'usepointgroup :vlax-true)
(vlax-put exportoptions 'pointgroup "Trees")
(vlax-put exportoptions 'transformcoordinate :vlax-false)
(vlax-invoke
  points
  'exportpoints
  "D:\\mypointfileexport.csv"
  "PENZD (comma delimited)"
  exportoptions
)
(vlax-release-object exportoptions)

 

Thank you very much.

I've been running into your work around the forums and it has been the SOLE reason that I have been able to make it as far as I have when customizing Civil 3D. So thank you for all of your hard work. I'm glad you took the time to help on my post. And glad that @john.uhden tagged you lol, thank you.

 

Best,

~DD

 

 

0 Likes
Message 16 of 21

Jeff_M
Consultant
Consultant

@CodeDing glad I could help. For future C3D related coding questions, I suggest posting them to the C3D Customization forum. I check there multiple times a day, but rarely venture over to the Lisp forum any longer.

Jeff_M, also a frequent Swamper
EESignature
Message 17 of 21

Sea-Haven
Mentor
Mentor

Knowing the names of options reveals a new world of CIV3d.

 

(strcat "AeccXLand.AeccPointExportOptions." C3D)

is there any documentation about the options is it in the developers help if so can be it be accessed public ? The old CIV3D was a lot more open with examples.

 

The one thing though is that it does not use the export dialog, I am sure will think of some other dialogs where have to input values, "import PXYZD" comes to mind as a menu press and just pick file. Half way there.

; IAeccPointImportOptions: IAeccPointImportOptions interface
; Property values:
; AddOffsetFrom = 0
; AdjustElevation = 0
; ExpandCoordinateData = 0
; PointDuplicateResolution = 0
; PointGroup = ""
; SequenceFrom = 0
; TransformCoordinate = 0
; UsePointGroup = 0

0 Likes
Message 18 of 21

CodeDing
Advisor
Advisor

@Sea-Haven ,

 

This old documentation from 2012 is what has been helping me understand the Civil 3D backend better.

This is where the Point Export Options object is mentioned, I just had no idea how to get to it.

 

http://docs.autodesk.com/CIV3D/2012/ENU/API_Reference_Guide/com/!!CLASSES_AeccXLandLib.htm

 

Best,

~DD

0 Likes
Message 19 of 21

Sea-Haven
Mentor
Mentor

Often the objects are not where you would think to look for them, others can edit directly. I just play around the edges.

 

Should be able to pick file, points import and surface is made a couple of steps less.

 

This code though and link has helped.

 

0 Likes
Message 20 of 21

Jeff_M
Consultant
Consultant

@Sea-Haven@CodeDing asked for a way to skip any user input which is what my example shows. It would be very simple to change the code to be a function which accepts the PointFileFormat and FileName (or any other options you'd want to set differently each time) as arguments. Then you could call it with hardcoded values or from a front-end that uses a dialog to get those values.

 

The 'help' for the COM API has not been updated since C3D 2012, as CodeDing noted. However, neither has the COM API itself. The only changes are the Release numbers needed to access them.

Jeff_M, also a frequent Swamper
EESignature