Importing X and Y Coordinates for Custom made blocks from excel.

Importing X and Y Coordinates for Custom made blocks from excel.

MikeNowak1
Explorer Explorer
827 Views
6 Replies
Message 1 of 7

Importing X and Y Coordinates for Custom made blocks from excel.

MikeNowak1
Explorer
Explorer

Hello,

I collect x and y coordinates ,and elevations in the field that correspond with a wooden survey stake.

These are uploaded onto my computer via excel file.

In AutoCAD, For any given (custom made block)location in our plans we have a name attribute, elevation attribute, and then position x and position y. 

I would like to be able to import the coordinate list and have the preset custom made block populate in the assigned imported x,y coordinates. If it was able to give the elevations and number assigned that would be a big plus. 

Thank you 

**Attached is the custom block with BORE being the name of the location**

Block.JPG

0 Likes
828 Views
6 Replies
Replies (6)
Message 2 of 7

Sea-Haven
Mentor
Mentor

I have something and if you post a sample xls and dwg as need blocks to test, may be able to do something for you.

0 Likes
Message 3 of 7

MikeNowak1
Explorer
Explorer

site.jpg

 

0 Likes
Message 4 of 7

pbejse
Mentor
Mentor

@MikeNowak1 wrote:

...

I would like to be able to import the coordinate list and have the preset custom made block populate in the assigned imported x,y coordinates.

...


What determines the block to be inserted? Is there any item on the data imported from an excel file that dictates which data belongs to what block ? There are 3 blocks on your sample drawing Bore, Boring and Spot Elevation. 

Do you prefer to prompt the user for the block name? 

("B-6" 1821784.629 1146208.468 nil "B-6") 
("PRS122673028712" 1775204.114 1117259.794 763.864 nil) 
("B6" 1821782.349 1146208.402 624.325 "B-6") 

Two of them them has "B-6",  1 has a Z value and the other one doesn't, and what is the deal with the second item on the list above?  

 

 

0 Likes
Message 5 of 7

MikeNowak1
Explorer
Explorer

The list at the top of the excel file is what was imported into the gps we use. In the field the bottom list is the coordinates and elevations at/near those locations and the excel file is an export from the gps. 

 b-6, y cord number, x cord number, elevation,  b-6

the b-6 listed twice is just a formatting thing for the gps. either works for us

the z value is the elevation.

hope that answers the questions

thank you

0 Likes
Message 6 of 7

Sea-Haven
Mentor
Mentor

Like Pbe excel is confusing but I have a select range to use from Acad just have to find time to write it and would use block "Boring", also I bedited the block and added a wipeout so no need for hatch. Have other stuff to do 1st.

0 Likes
Message 7 of 7

Sea-Haven
Mentor
Mentor

Ok this is very much customised to what you have supplied so its real short. You open your excel file then run the lisp. It will ask you to select a range in the excel file. The blocks should appear.

 

A couple of things make sure Alan excel Library.lsp is in a supported path or edit the (Load to correct directory where its saved.

 

I have not added the open or check is correct excel open at this stage that would be next step. Its in the library code.

 

Lastly I would add a background mask to your block send to back so no need for white hatching.

 

SeaHaven_0-1661746084147.png

 

SeaHaven_1-1661746123308.png

 

 

 

; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/importing-x-and-y-coordinates-for-custom-made-blocks-from-excel/td-p/11373585


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


(defun c:boring ( /myxl blk pt)
(if (not getrangexl2)(load "Alan Excel Library"))

(or (setq myxl (vlax-get-object "Excel.Application"))
    (setq myxl (vlax-get-or-create-object "excel.Application"))
)
(vla-put-visible myXL :vlax-true)
(vlax-put-property myxl 'ScreenUpdating :vlax-true)
(vlax-put-property myXL 'DisplayAlerts :vlax-true)

(getrangexl2)
					
(princ *ExcelData@)

(setq attreq 1)	
(foreach blk *ExcelData@
(setq pt (list (car blk)(cadr blk)))
(command "-insert" "boring" "s" 1.5 pt 0.0 (rtos (nth 2 blk)2 2) (nth 3 blk))
)

(princ)
)	

 

 

 

0 Likes