Lisp for creating circles by diameter from point description?

Lisp for creating circles by diameter from point description?

Anonymous
Not applicable
5,171 Views
36 Replies
Message 1 of 37

Lisp for creating circles by diameter from point description?

Anonymous
Not applicable

Hey everyone, first post.

 

Thanks in advance for taking a look and for any suggestions you have.  I'll try to keep it as simple as possible:

 

I'm importing a ton of points into a drawing from CSV files. 

Format is Point | Northing | Easting | Elevation | Description. 

For example:  4011026 | 51105.600 | 6553.000 | 352.631 | 0.352

 

What I'd like to do seems like a fairly simple automated task... but I'm totally unfamiliar with LISP programming.

 

The jist of the programming should look for any point, create a circle (center is point N/E/Z) and define the circle diameters from the point descriptions.

 

I would be forever in your debt if you could suggest any sorcery to aid me.

 

Thanks again.

0 Likes
Accepted solutions (2)
5,172 Views
36 Replies
Replies (36)
Message 3 of 37

antoniovinci
Advisor
Advisor

Would you please upload here the huge CSV file?

0 Likes
Message 4 of 37

Anonymous
Not applicable

Here is an example CSV...

 

There are a ton more, we just have them seperated by IFC drawing.

0 Likes
Message 5 of 37

odoshi
Collaborator
Collaborator

Sent you a PM. What are the units for the diameter? Feet?

 

Also, what AutoCAD version are you running?

 

Regards,

 

 

Mike Caruso
Autodesk Certified Instructor 2014
AutoCAD/Civil 3D Autodesk Certified Professional 2014, 2015, 2018
www.whitemountaincad.com
0 Likes
Message 6 of 37

antoniovinci
Advisor
Advisor

Given that you can build such an automatic script to draw the circles by radius=descr:

 

_circle x1,y1,z1 descr1

 _circle x2,y2,z descr2

...

 _circle xN,yN,zN descrN

 

here's a pure Map solution.

 

1] load the attached DWG

2] run _MAPTOPOCREATE

3] choose node topology

4] run _MAPBUFFER

5] as buffer method, enter O

6] as object data type, enter O

7] as table name, enter CERC

8] as object data field, enter FIELD_5

9] type a name of the brand new topology

10] press Enter until quitting the command

11] enjoy the pseudo-circles on a radius=description base

Message 7 of 37

Anonymous
Not applicable

Hello!

 

Sorry on the delay, I was finished work for the day but have resumed now.  Currently giving what antoniovinci suggested but I'm not sure it's going to work as well as a LISP.  I'll keep trying it out and see if it will suffice, thank-you for the suggestion.

 

Anyway, my PC has civil 3d 2015, but most of our other installations are 2013.

 

The diameters of the circles are in meters, so for example .345 is 345mm.

 

 

Thanks!!!

0 Likes
Message 8 of 37

AllenJessup
Mentor
Mentor

Try setting up a description key for it. You'll have to edit the point files so the description 0.352 end up something like CIR 0.352. A search and replace - replace 0. with CIR 0. on the column should do it. I'm not expert at description keys. So search this group for 'Description Key tree diameter' and also see HERE for some tips.

 

See HERE also. Looks like a good description of the process.

 

Allen

Allen Jessup
CAD Manager - Designer
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

Message 9 of 37

Jeff_M
Consultant
Consultant
Accepted solution

@Anonymous wrote:

 

What I'd like to do seems like a fairly simple automated task... but I'm totally unfamiliar with LISP programming.

 

The jist of the programming should look for any point, create a circle (center is point N/E/Z) and define the circle diameters from the point descriptions.

 


Welcome to the forums!

Yes, this is a fairly simple autolisp routine: Command name is CIRCLEPOINTS

(defun c:circlepoints (/ diam ent idx mspace pt ss)
  (vl-load-com)
  (if (setq ss (ssget '((0 . "AECC_COGO_POINT"))))
    (progn
      (setq idx -1
            mspace (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))
	    )
      (while (setq ent (ssname ss (setq idx (1+ idx))))
	(setq pt (vlax-ename->vla-object ent))
	(if (not (wcmatch (setq diam (vlax-get pt 'rawdescription)) "*@*"))
	  (progn
	    (vlax-invoke mspace 'addcircle (vlax-get pt 'location) (atof diam))
	    )
	  )
	)
      )
    )
  (progn)
  )

 

Jeff_M, also a frequent Swamper
EESignature
Message 10 of 37

Jeff_M
Consultant
Consultant

Oops, I knew it was too early to be writing lisp. I'd forgotten that the AddCircle takes the radius, not the diameter, so it's making the circles twice as big as they should be. Change this little bit of code (atof diam) to this (* (atof diam) 0.5) and it will then place them with the correct diameters..

Jeff_M, also a frequent Swamper
EESignature
0 Likes
Message 11 of 37

Anonymous
Not applicable

Jeff's lisp will be much nicer, but you can write scripts (Acad SCR) within Excel for cases like that, too, just concatenate columns into a script text column, the copy that column out, paste into Excel.

 

(I used to do that kind of stuff with lisp, but don't write it enough to do it efficently at all, anymore.)

0 Likes
Message 12 of 37

antoniovinci
Advisor
Advisor

@ Tom

 

That's exactly what I meant in the first part of my "05-02-2015 08:11 AM" post...

 

@ Jeff

 

Your brilliant Lisp doesn't work in my Map2006: would you please make a "downgraded" release of your code?

 

0 Likes
Message 13 of 37

Anonymous
Not applicable

Sorry, Antonio....I did not even see that part of your answer.  (I just kind of skim through the posts.)

 

My revised answer:  See Antonio's answer, the first part.  It is the 'simplest' and 'easiest' way.  😉

Message 14 of 37

Jeff_M
Consultant
Consultant

@antoniovinci Map2006? The lisp is designed to work with only Civil3D cogopoints, not sure if C3D2006 had the cogopoints exposed in the API.

Jeff_M, also a frequent Swamper
EESignature
0 Likes
Message 15 of 37

hencoop
Advisor
Advisor

At least one version before 2013 they were "AECC_POINT" objects.  if that's what they were back then just changing the object name should fix it.

AutoCAD User since 1989. Civil Engineering Professional since 1983
Product Version: 13.6.1963.0 Civil 3D 2024.4.1 Update Built on: U.202.0.0 AutoCAD 2024.1.6
                        27.0.37.14 Autodesk AutoCAD Map 3D 2024.0.1
                        8.6.52.0 AutoCAD Architecture 2024
0 Likes
Message 16 of 37

Anonymous
Not applicable
Accepted solution

Just want to throw a quick post up - I'm on days off but all you guys are great for suggestions and I'm seeing alot of ideas being bounced back and forth.  This is a good topic!!!  Perhaps the Autodesk gods shall implement such an application in future builds.

 

Anyway, the user @odoshi wrote one for me! it works flawlessly.  The best part is that you don't even need to import / define the points beforehand.  You just browse to where the csv is and it creates the circles.  You can always import the points/create a point group for them afterward.

 

Thanks to him!!!

0 Likes
Message 17 of 37

ccpow2003
Observer
Observer

Can you share this lisp by chance. I am looking to draw a circle based on the diameter of a tree to calculate tree canopy area.

0 Likes
Message 18 of 37

jmayo-EE
Mentor
Mentor

I'd go with Allen's post, description keys do this automatically with zero extra steps in every file for every project. You should even have to think about it.

John Mayo

EESignature

Message 19 of 37

jefflambert9091
Advisor
Advisor

I have this setup with Description Keys. Works Great. Some times I will just have them shoot the tree and a drip line and I will modify the description in the tree shot with the distance. Never could think of a way to use both points. If its a major tree will just do linework on the dripline. 

Jeff
Civil 3D 2024
0 Likes
Message 20 of 37

hencoop
Advisor
Advisor

IMHO (and experience) description keys for things like various sizes and types of trees are far too cumbersome to create, maintain and utilize... unless that's your only option.  For me it was much easier to create a lisp program that reads points in the drawing or directly from the point files (CSV) themselves and uses the point descriptions to determine the type and size of tree it needs to be and then place the appropriate tree block at the appropriate scale on the appropriate layer.

This is the core of the code I use to collect the information from AECC_COGO_POINT objects in the drawing (point files are much simpler.  I just use DOS_STRTOKENS from DOSLIB to make each individual point data list and then add that to my all-points data list)

 

(SETQ cogopt       (VLAX-ENAME->VLA-OBJECT this_ename)
      parapoint_bb (VLAX-GET-PROPERTY cogopt "Elevation") ;elevation
      parapoint_aa (VLAX-GET-PROPERTY cogopt "Number") ;point no.
      parapoint_cc (VLAX-GET-PROPERTY cogopt "FullDescription") ;description
) ;_ end of SETQ
(IF (OR (NOT upd_exist_lst)
        (MEMBER (VLAX-GET-PROPERTY cogopt "FullDescription") prev_desc_lst)
    ) ;_ end of OR
    (PROGN (SETQ ipnt
                 (LIST (VLAX-GET-PROPERTY cogopt "Easting")
                       (VLAX-GET-PROPERTY cogopt "Northing")
                       (IF (AND (/= (TYPE parapoint_bb) 'REAL)
                                (OR (EQ (TYPE (ATOF parapoint_bb)) 'INT)
                                    (EQ (TYPE (ATOF parapoint_bb)) 'REAL)
                                ) ;_ end of OR
                           ) ;_ end of and
                         (ATOF parapoint_bb)
                         (IF (EQ (TYPE parapoint_bb) 'REAL)
                           parapoint_bb
                           0.0
                         ) ;_ end of if
                       ) ;_ end of if
                 )
                 dcapntblklst 
                 (APPEND
                   dcapntblklst
                   (LIST (LIST parapoint_aa
                               (LIST parapoint_aa parapoint_cc parapoint_bb ipnt)
                               ipnt
                         ) ;_ end of LIST
                   ) ;_ end of LIST
                 ) ;_ end of APPEND
           ) ;_ end of SETQ
           (aecc_pts_finish)
    ) ;_ end of PROGN
) ;_ end of IF

 

My routine steps through the list examining the descriptions for trees and their size (using WCMATCH and the robust wildcard matching available in Autolisp) and places the block accordingly.  If the tree size cannot be determined I PRINC the point description to the command line and wait for the size to be keyed in.  Standard blocks for a specific type of tree are scaled to approximate the canopy size based upon the trunk size in the description (or the keyed in trunk size if the description has none).  All of the trees of various types and sizes are drawn in just a second or two if all the descriptions have sizes.

AutoCAD User since 1989. Civil Engineering Professional since 1983
Product Version: 13.6.1963.0 Civil 3D 2024.4.1 Update Built on: U.202.0.0 AutoCAD 2024.1.6
                        27.0.37.14 Autodesk AutoCAD Map 3D 2024.0.1
                        8.6.52.0 AutoCAD Architecture 2024
0 Likes