automation query

automation query

ctnycc
Advocate Advocate
1,351 Views
10 Replies
Message 1 of 11

automation query

ctnycc
Advocate
Advocate

Good day

 

I was wondering if anybody can help with the above.

 

I would like to use my tmeplate which on asking via a dialog box, it will look to automatically loading in a block id that has been entered into the dialog box and load it intot hte drawing from a preassigned directory on the network drive.

 

Can anyone help on this?

 

Thanks in advance

 

regards

 

Colin

 

0 Likes
Accepted solutions (1)
1,352 Views
10 Replies
Replies (10)
Message 2 of 11

SeeMSixty7
Advisor
Advisor

Can you expand a little more?

 

I gather you want to be able to have a dialog box that asks you to select a template (dwt) then start a new drawing using that template and then insert a block or a title block id from a dialog box.

 

From that description it sounds like just use a template using standard AutoCAD and then possibly create a startup function that prompts you to select a block id or prompts for the desired attribute value.

 

So can you elaborate a bit more?

 

Good luck,

 

 

0 Likes
Message 3 of 11

ctnycc
Advocate
Advocate

Hi seem67,

 

I will detail what i am looking for,

 

Ihave a dwt template which i have opened up in autocad with all the default layer settings, no problem straight forward.  The bit i am really after is where on starting a lisp routine which will start a dialog box to open up and ask for the insertion of an ordnance survey block ( the block is a geographic map tile) from a default network drive location.   The block can be either a dxf or a dwg file.  typing the file name into the dialog and clicking enter will insert the block at the correct location in the model space.  This might be repeated several times to "stitch" all the blokcs together to produce the map for the location plan.

 

To do this would save a lot of time rather than having to go through the directories and files to select the relevant one each time you load in a tile. 

 

Hope this has clarified me idea?

 

Regards

 

Colin

 

0 Likes
Message 4 of 11

SeeMSixty7
Advisor
Advisor

What controls the insertion point of the ordnance block? Is there some data within the block to get that or is every block inserted at 0,0,0 and the components within the block are already at the proper coordinates in the block?

 

Do you want the entire directory brought into the drawing or just certain ones? How are they identified for your drawing?

Is user interaction required or can you provide a piece of information to allow the computer to locate the blocks? Prefix or suffix on the blocks? Folder Location? Drawing name of the file the ordnance block are being inserted into?

 

It sounds like you could pretty easily pick a file or folder and have AutoCAD import and insert all of your ordnance blocks. Just need to nail down the specifics on how to select all the blocks to be inserted and where the insert coordinates come from.

 

Are you familiar with developing AutoLISP code?

 

Good luck,

0 Likes
Message 5 of 11

SeeMSixty7
Advisor
Advisor
Accepted solution

I rec'd a message that you replied, but that reply is gone. Here is a quick routine to do what you asked. If you want to expand on it more there are several options. This one will just have you pick the block and will just insert it at 0,0,0 for you and then just keep prompting you to select a new block based on the path of the last block you selected. The first time the dialog pops up it uses the current drawings path.

 

(defun c:IOB( / defaultpath currattreq blocktoinsert)
	(setq defaultpath (getvar "DWGPREFIX")
		  currattreq (getvar "ATTREQ")
	)
	(while (setq blktoinsert (getfiled "Select Block to insert: " defaultpath "dwg" 16))
		(setvar "ATTREQ" 0)
		(command "-insert" blktoinsert (list 0.0 0.0 0.0) "" "" "")
		(setvar "ATTREQ" currattreq)
		(setq defaultpath (strcat (vl-filename-directory blktoinsert) "\\"))
	)
)

 

Some thoughts for improving or reducing the user input.

 

If you want some different options you could consider a text file with the blocks you wish to insert and just have the routine read the file and insert them, no more user picks needed. If you want all the blocks in the directory, you could select the first file and then have the routine just insert every dwg file in that folder.

 

Good luck,

Message 6 of 11

dbroad
Mentor
Mentor

Unless you have thousands of these symbols, skip LISP and create tool palettes with your symbols.

Architect, Registered NC, VA, SC, & GA.
0 Likes
Message 7 of 11

ctnycc
Advocate
Advocate

Approximately 6500 items.

0 Likes
Message 8 of 11

ctnycc
Advocate
Advocate

Hi Seem67

 

Yes i did reply, for some reason it hasn't come up!!!.

 

I willl try the code you have provided and come back to you.

 

REgards

 

Colin

 

0 Likes
Message 9 of 11

ctnycc
Advocate
Advocate

Hi  Seem67

 

Wow! impressive what a little bit of conde can do.

 

As we are stuck with PC's that are locked i have to initially change the directory to the desired location,  after that it works a treat.

 

the default file location for the dwg is M:\mapinfo\DWG and dxf is M:\mapinfo\DXF\Mastermap_Topo, maybe it could be incorporated into the code?

 

So i thought i would try it with the 8 character reference file name however these are on the dxf file format.  is there any way to make it change over to this format?

 

It seems in spite of my email disappearing you must have read my mind!

 

Thanks again.

0 Likes
Message 10 of 11

ctnycc
Advocate
Advocate

Thanks Seem67,

 

I had a look at the code in detail and changed the dwg to dxf.  youhave been a great help.

 

Regards

 

Colin

 

Message 11 of 11

SeeMSixty7
Advisor
Advisor

Colin,

 

I'm glad to hear that worked out for you. I'm also glad to see you figured out how to handle the dxf part on your own!

 

Good luck,

 

Clint

0 Likes