Jump to content

Replacing points with objects


Recommended Posts

Posted

I had a the same problem and I was pulling my hair out.

 

A kind programmer on here felt sorry for me and came to my rescue

 

He wrote me a program

 

(defun c:qqq ()

(setq fp (open "c:\\Documents and Settings\\donald.christensen\\My Documents\\coords.txt" "r") lst '() i 0)

(while (setq a (read-line fp))

(setq lst (cons a lst))

)

(close fp)

(repeat (length lst)

(command "._insert" "lsection" (nth i lst) "" "" "")

(setq i (1+ i))

)

)

 

It will insert a block.

I made a block called lsection. Your block can be called diamond

 

 

 

I inputed the coordinates in an ascii format and saved it as c:\\Documents and Settings\\donald.christensen\\My Documents\\coords.txt

 

0,16.5

76.59,16.63

76.59,16.67

134.238,16.77

134.238,16.81

187.24,16.90

187.24,16.94

268.36,17.08

268.36,17.12

315.5,17.20

 

I like ascii because it is simple. Also, most programs will convert to it.

 

I first wrote my coordinates in Excel then copied and pasted them in ascii

 

I'm sure he could have written it to read an Excel file direct however, for simplicity and ease to debug, I prefure this

  • Replies 26
  • Created
  • Last Reply

Top Posters In This Topic

  • fuccaro

    8

  • rustysilo

    8

  • rusty

    7

  • rookie37

    2

Posted

I would recommend you to turn Osnaps off when you run that Lisp. Otherwise -in some conditions- it is possible to get your blocks inserted in wrong place!

Posted

That might explain some of the troubles I was having

 

My ascii file had about 50 coordinates in it

 

However it would insert only 35 blocks.

 

Actually I think it was 50 blocks but some had 5 copies of the same block

 

I'm embarrased, I can't remember who wrote it for me. Was it you?

 

If so, thank you!

Posted

Sorry, I can't remember each routine I wrote along the years. The code doesn't look familiar to me but who knows!

I just recognize an old problem I had with the COMMAND function: it captures the closes snap points. So a good routine should save the Osnap settings, deactivate it while it draws somethings on the screen and finally it should restore the initial state.

A better routine will not use the Command function to draw entities.

Posted

I don't know the author of the lisp you posted above, but I think (s)he don't mind if I adjust it a litle bit. Here is a better version: it deals with the OSNAP as I explained.

Be sure you select a file when prompted :twisted:

 
(defun c:p2b( / file f a osmode);PointsToBlocks
 (while (not file)
   (setq file (getfiled "Input file" "coords" "txt" 4))
   )
 (setq f (open file "r")
osmode (getvar "OSMODE")
)
 (setvar "OSMODE" 0)
 (while (setq a (read-line f))
   (command "._insert" "lsection" a 1 1 0)
   )
 (setvar "OSMODE" osmode)
 (princ)
 )

Posted

I like your suggestion on using IMPORTXYZ. I have just started using it recently with some site survey work being submitted by a firm which uses Land Desktop. Funny how these guys didn't even know that your regular AutoCAD does not import points. They sent me a text file with points and just expected anyone running AutoCAD could import them instantly. You need something like IMPORTXYZ. It's not that fancy but you can't beat the price....FREE.

 

And one more comment about Civil 3d being the easiest way. You forgot to mention that this method will also set you back around $7,000 before it will become that easy. In today's lean and mean business world, IMPORTXYZ is a nice tool to have around.

Posted

:lol: Yeah the cost can be prohibitive for some, but it still would be the easiest way IF you have Civil 3D.

 

Another good way to do it for free is to use SiteTopo to open said .txt point file and then export that to .dxf and open in Acad where you could then modify the point blocks (or use block replace) to add your symbology.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...