Field to Finish, LISP Routines and auto drafting advanced concepts

Field to Finish, LISP Routines and auto drafting advanced concepts

kelly.adams93PU9
Explorer Explorer
3,354 Views
9 Replies
Message 1 of 10

Field to Finish, LISP Routines and auto drafting advanced concepts

kelly.adams93PU9
Explorer
Explorer

Let me start by saying, I am not a coder.  I am a surveyor who is trying to automate linework, point insertion, and drafting.  We are in C3D 2019 currently, so the newer coding languages are out for me.

 

I currently have a functioning LCS, DKS, and a few minor LISP routines for my field crews to check their work.  My current routine runs them through the IMPORTSURVEYDATA routine and then adds lines from the LCS to the surface as breaklines and gives us a decent rough draft so they can check their work before handing it to the office staff.  We are also using the same routine in the office to handle the initial import and drafting and simply deleting the surface for 2D jobs. The surface is in the template along with a point group so the LISP runs update point group and rebuild surface commands to "auto generate" the surface because if/then commands are above my skillset currently.  That is okay, too.  We are slow enough that I can take the time to learn how to write them from watching YouTube.

 

Take my current auto drafting goal that I feel is possible, and I'm pretty sure it is because my former employer had an in-house written program that originally ran over Civil 3D 2009 that could do this, so I assume the commands are all there.  I would like to be able to write the following LISP routine:

  1. Search for points by a list of codes (say catch basins and drop inlets)
  2. Inverse between the two points following the catch basin insertion point (these would be on the face of the curb to define the rotation of the point marker)
  3. Verify that next to points have proper code of rotation shots (optional, but preferable)
  4. Change value of point marker rotation to match inverse (may require a simple math problem to make rotation work) between two rotation shots
  5. Repeat 1-4 until there are no more shots on the list

I think I can write the LISP routine, or at least a rough draft of one, and test and debug my way through most of it.  However, I am overwhelmed and at a loss trying to find the perfect Google keyword search to find the LISP routine commands that I need to make it happen.  I found the 2013 AutoCAD LISP command guide, but it is 298 pages and doesn't even have the VLA and VLAX commands in it, and I can't find an upgraded version to 2019.

 

TL;DR - I'm really struggling to find the right resource to find the proper commands to use in LISP routines to create the programs that I want to write and I need help.

0 Likes
Accepted solutions (1)
3,355 Views
9 Replies
Replies (9)
Message 2 of 10

Jeff_M
Consultant
Consultant
Accepted solution

The C3D COM API is what is used with (vlax-invoke, (vlax-invoke method, (vlax-get-property, & vlax-set-property methods. Figuring out how to implement them properly is half the fun... Search this forum for specific examples by myself, @hosneyalaa , @hippe013 , @tyronebk, and others.

 

Then ask specific questions on the coding by including what you've developed so far and need help with.

 

Good luck and try to have fun with it.

Jeff_M, also a frequent Swamper
EESignature
Message 3 of 10

hosneyalaa
Advisor
Advisor

Hi all 

Thanks @Jeff_M 

Hi @kelly.adams93PU9 

Because my language is not good for understanding you correctly

 

Can you explain with example drawing 

And attached it 

 

0 Likes
Message 4 of 10

hippe013
Advisor
Advisor

TL;DR - I'm really struggling to find the right resource to find the proper commands to use in LISP routines to create the programs that I want to write and I need help.

 

You found the right resource. It's here, on these forums. 

Happy to help with questions on LISP and .NET. Majority of the commands that I write are Civil and Survey related. 

 

 

0 Likes
Message 5 of 10

kelly.adams93PU9
Explorer
Explorer

Thank you for your help.  I've been doing research into what you sent me, and it's what I was looking for.  Sadly, my massive company has locked out our computers to a point that I can't run a code compiler like Visual Studio to actually write the code I need.  I wish I was joking.

 

Thanks everyone for trying.

0 Likes
Message 6 of 10

hippe013
Advisor
Advisor

LISP does not need to be compiled and can written in something as simple as notepad. I do recommend using a text editor such as VS Code, Notepad++, or even the legacy IDE that comes with AutoCAD. However, DotNET projects do need to be compiled into a dll. It is a shame that you company feels the need to lock down computers to such a degree. 

0 Likes
Message 7 of 10

rgrainer
Collaborator
Collaborator
  1. "Search for points by a list of codes (say catch basins and drop inlets)
  2. Inverse between the two points following the catch basin insertion point (these would be on the face of the curb to define the rotation of the point marker)
  3. Verify that next to points have proper code of rotation shots (optional, but preferable)
  4. Change value of point marker rotation to match inverse (may require a simple math problem to make rotation work) between two rotation shots
  5. Repeat 1-4 until there are no more shots on the list "


 

 

Are you sure you really need lisp? Basic lisp to do simple things is not that difficult, but to not be a coder and wanting to do what you are asking or seeking to learn is a tall order, not impossible, just something to keep in mind.
 
Do you use point groups? item one on your list might be handled by utilizing them. 

 

The same thing can be done for your item two. Depending on how they are coded, you can connect them with a survey figure and label them to show the inverse or whatever  you need. Do you know about point group queries?

 

items three depends upon the codes used, if they are wrong they are not added to the point group, it also depends on how you use wildcards in your point codes. Codes need to be edited to make sure correct description keys are being used, before importing the database.

 

item four does not make sense to me. What rotation are you talking about?, between what shots? Please explain clearly what you are asking or talking about here.

0 Likes
Message 8 of 10

kelly.adams93PU9
Explorer
Explorer

So at my previous company, they had an in-house written add on program to Civil 3D that would do everything I am trying to re-create.  That's how I know this is possible.  I don't know how it was coded, but after seeing the .NET language I was linked to above, I imagine the answers are all in there.  I do not use point groups in my field to finish routine, but rather I use a description key set to address point styles, labels, and layers.

 

To flesh out the process, you locate a left wing catch basin over the center of the manhole.  The DKS inserts a Cogo Point there with the LWCB block as the point marker.  Then, the next two shots the field guys take are along the front face of the catch basin (think face of curb).  The program then recognizes the LWCB code, looks for the rotation shots immediately after, inverses between the two rotation shots, takes that azimuth that it computes, goes back to the LWCB and modifies the Point Marker Rotation value such that the catch basin is automatically rotated to where it sits in real life.

 

But, again, it looks like the commands I need to do this are all in .NET and my company's IT policy is too restrictive for me to compile codes into dll files so I can make it happen.  Everything I can do is effectively limited to VLISP.

0 Likes
Message 9 of 10

Jeff_M
Consultant
Consultant

@kelly.adams93PU9 wrote:

Everything I can do is effectively limited to VLISP.


This can be done in lisp. This does what you described, although it does not have any provisions for catching errors and may need some additional work. But it should get you started.

(defun c:processinlets (/ C3DAPP C3DDOC P1 P2 POINTS)
  (vl-load-com)
  (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)
			 )
		       )
		   C3D (vla-getinterfaceobject
			 (vlax-get-acad-object)
			 (strcat "AeccXUi"
				 module
				 ".Aecc"
				 (if (= (strcase module) "LAND")
				   ""
				   module
				 )
				 "Application."
				 C3D
			 )
		       )
	     )
	)
      C3D
    )
  )
  (setq	c3dApp (getaeccapp "Land")
	c3ddoc (vlax-get c3dapp 'activedocument)
	points (vlax-get c3ddoc 'points)
  )
  (vlax-for p points
    (if	(wcmatch (strcase (vlax-get p 'rawdescription))
		 "*BASIN*,*DROP*"
	)
      ;;edit to use your codes for basins and drop inlets
      (progn
	(setq p1 (vlax-invoke points 'find (+ (vlax-get p 'number) 1)))
	(setq p2 (vlax-invoke points 'find (+ (vlax-get p 'number) 2)))
	(if (and (= (strcase (vlax-get p1 'rawdescription)) "TC")
		 ;;this is one of the rotation shots
		 (= (strcase (vlax-get p2 'rawdescription)) "TC")
		 ;;this is one of the rotation shots
	    )
	  (progn
	    (vlax-put
	      p
	      'rotation
	      (angle (vlax-get p1 'location) (vlax-get p2 'location))
	    )
	  )
	)
      )
    )
  )
  (princ)
)

Jeff_M, also a frequent Swamper
EESignature
Message 10 of 10

kelly.adams93PU9
Explorer
Explorer

Oh my goodness.  You didn't have to do this, but I'm very grateful you did.  I'm going to study it and try to learn from it so I can make more things happen.  I'll modify it next chance I get and let you know how it goes.  

0 Likes