Automatic placement of elements

Automatic placement of elements

tulp1982
Explorer Explorer
1,119 Views
8 Replies
Message 1 of 9

Automatic placement of elements

tulp1982
Explorer
Explorer

Hi there,

 

I would like to know if it is possible to place a large quantity of elements (circles for example), based on a list of X-Y coordinates in autocad 2018.

 

For example:

1    118.73   ,   25.54
2    220.53  ,   23.91
3    119.12   ,   22.42
4    121.91   ,   21.99
Etcetera

 

Reason for asking; I have almost 2000 coordinates which I want to incorparate in a cad drawing without any errors.

 

Many thanks,

 

 

0 Likes
1,120 Views
8 Replies
Replies (8)
Message 2 of 9

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

>> I have almost 2000 coordinates

No problem, you might think to start at 200000 circles, but not for 2000 😉

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 3 of 9

tulp1982
Explorer
Explorer

Would you like to explain me which commands I have to choose to create these circles based om the list of coordinates?

Thank you,

 

 

0 Likes
Message 4 of 9

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

>> which commands I have to choose to create these circles

Which product do you have?
Plain AutoCAD does not have a command to import coordinates and create circles from that, but e.g. AutoCAD Map 3D or AutoCAD Civil 3D have functions that might help to do that.

 

For plain AutoCAD you might look to that video which shows what to do in Excel to create a script and then run the script that inserts blocks.

 

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 5 of 9

tulp1982
Explorer
Explorer

Hi Alfred,

 

This is exactly what I am looking for!

But unfortunately it doesn't work. I am quite confident that I copied the numbers and formulas correctly, but I get various errors.

 

I've attached the excel file and a printscree from the error. Can you maibe check if I did something wrong?

Thank you!

0 Likes
Message 6 of 9

j.palmeL29YX
Mentor
Mentor

Assuming your "source" is a CDF file (a text file in which the X-, Y- and Z-value of each coordinate are separted by a comma) or a SDF file (a text file in which the X-, Y- and Z-value of each coordinate are separted by one or more space(s) ) you can try the attached LISP. (Don't worry about the german comments, it works in all other language versions of AutoCAD too).

;;; Eine CDF-Datei (Comma Delimited Format) enthält eine Koordinate je Zeile,
;;; wobei die X-, Y- und Z-Werte durch je ein Komma getrennt sind:
;;;
;;;    2.333,4.23,8.0
;;;    -4.33,0.0,6.3
;;;    0.322,5.32,0.0
;;;    ...
;;;
;;; In der CDF-Datei dürfen keine Leerzeichen und keine Leerzeilen enthalten sein.
;;;
;;;
;;;
;;; Eine SDF-Datei (Space Delimited Format) enthält eine Koordinate je Zeile,
;;; wobei die X-, Y- und Z-Werte durch ein oder mehrere Leerzeichen getrennt sind:
;;;
;;;    2.333  4.23   8.0
;;;   -4.33   0.0    6.3
;;;    0.322  5.32   0.0
;;;    ...
;;;
;;; Es sind wahlweise 2D-oder 3D-Koordinaten zulässig.
;;;
;;; Als Dezimaltrennzeichen ist in jedem Fall der Punkt zu verwenden!


(defun C:ASCPOINT (/ f bm hi format input read-point line plist ss)
  (cond	((eq "" (setq f (getfiled "" "" "" 0))))
	((not (setq f (open f "r")))
	 (princ "\nKann Datei nicht öffnen.")
	)
	(t
	 (initget "Space Comma")
	 (setq format
		(cond ((getkword "\nComma/Space delimited <Comma>: "))
		      (t "Comma")
		)
	 )
	 (initget "Copies Lines Nodes 3dpoly Pline Spline")
	 (setq input
		(cdr
		  (assoc
		    (cond
		      ((getkword
			 "\nErzeuge   Copies/Lines/Nodes/3dpoly/Spline/<Pline>: "
		       )
		      )
		      (t "Pline")
		    )
		    '(("Lines" . "_.line")
		      ("Copies" . "_.copy")
		      ("Nodes" . "_.point")
		      ("3dpoly" . "_.3dpoly")
		      ("Pline" . "_.pline")
		      ("Spline" . "_.spline")
		     )
		  )
		)
	 )
	 (setq read-point
		(cond ((eq format "Comma") cdf)
		      (t sdf)
		)
	 )
	 (setvar "cmdecho" 0)
	 (command "_.undo" "_g")
	 (setq hi (getvar "highlight"))
	 (princ "\nLese Daten...")
	 (while	(setq line (read-line f))
	   (cond ((setq line (strtrim line))
		  (setq line (read-point line))
		  (setq	plist (append plist
				      (cond ((eq input "_.pline")
					     (list (noz line))
					    )
					    (t (list line))
				      )
			      )
		  )
		 )
	   )
	 )
	 (close f)
	 (cond ((eq input "_.point")
		(setvar "highlight" 0)
		(command "_.point"
			 "0,0,0"
			 "_.copy"
			 (setq ss (entlast))
			 ""
			 "_m"
			 "0,0,0"
		)
		(apply 'command plist)
		(command)
		(entdel ss)
	       )
	       ((eq input "_.copy")
		(princ "\nWähle zu kopierende Objekte,")
		(while (not (setq ss (ssget)))
		  (princ "\nKeine Objekte gewählt,")
		  (princ " wähle zu kopierende Objekte,")
		)
		(setvar "highlight" 0)
		(command "_.copy" ss "" "_m" "0,0,0")
		(apply 'command plist)
		(command)
	       )
	       ((eq input "_.spline")
		(command input)
		(apply 'command plist)
		(command "")
		(command "")
		(command "")
	       )
	       (t
		(command input)
		(apply 'command plist)
		(command)
	       )
	 )
	 (command "_.undo" "_e")
	 (setvar "highlight" hi)
	)
  )
  (princ)
)


(defun cdf (l)
  (command "_.setvar" "lastpoint" l)
  (getvar "lastpoint")
)


(defun sdf (l)
  (read (strcat "(" l ")"))
)


(defun noz (p)
  (list (car p) (cadr p))
)


(defun strtrim (s)
  (while (eq " " (substr s 1 1))
    (setq s (substr s 2))
  )
  (while (eq " " (substr s (strlen s)))
    (setq s (substr s 1 (1- (strlen s))))
  )
  (cond	((eq s "") nil)
	(t s)
  )
)


(princ "\nC:ASCPOINT geladen.  Starte mit ASCPOINT. ")
(princ)

 

 

 

 

Jürgen Palme
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

0 Likes
Message 7 of 9

tulp1982
Explorer
Explorer

Alfred,

 

I just downloaded the excel file from the forum and tested it again and ik works now. So many thanks.

On little thing though. My coordinates are located with minimal distance from each other (0,2mm). Right now the script places cicles of 2mm which it way too large.

 

I there any way to insert smaller circles?

 

Thanks 

0 Likes
Message 8 of 9

tramber
Advisor
Advisor

My god !

Are you all advising our friend to run lisps for a simple script to build ?

 

_CIRCLE 0,0 5
_CIRCLE 10,0 15
_CIRCLE 20,0 25
...... ad libitum (just don't forget to turn the osnaps off)

I'm not "in" that topic, just having a look.

The only difficulty is the use of the concatenate formula in Excel before you copy what you build in a scr file 😁


EESignature

0 Likes
Message 9 of 9

tulp1982
Explorer
Explorer

It works guys,

 

Thanks for for the help!!

 

 

 

0 Likes