Jump to content
Skilled Warrior

Block Insert Lisp

Recommended Posts

Skilled Warrior

I am currently working for a cabinet company that provides drawings using over 250,000 different blocks. I am looking to see if anyone has written a lisp program that would make the insertion of these said blocks a lot easier...

 

Currently I have just been using the AutoCAD insert command and then browsing to find the correct folder that stores the different kinds of cabinet styles, then looking for the specific block name. I worked for a previous cabinet company that had this same set up but they would type in a command and it would bring up a pop up menu where I could then type in the name of the block and it would insert it no matter what folder it was in.

 

With having over 250,000 blocks I can't really use a pallette to pull from as I wouldn't know where to begin....

 

Any help would be greatly appreciative, sorry I don't know much about lisp programming but trying to learn.

Share this post


Link to post
Share on other sites
Skilled Warrior

That is a very interesting add-on program that I might be able to try...Not sure how well it will work seeing how I don't really know the blocks other than by the names and not the pictures, I could try messing around with it. Is there no Autolisp code that I could manipulate to work with the multiple folders and blocks that I have?

 

I currently manipulated a lisp file someone sent me that showed me how to use a command to insert a block, I started doing it for more cabinets but with 250,000+ blocks it would take too long....

 

 
(defun c: xxxxxxx ()
(setq insertpt1 (getpoint "\nPick Lower Left Corner of the cabinet: "))
(command "_insert" "G:\\DRAFTERS\\Casework\\yyyyyyy.dwg" insertpt1 "" "" "")
(princ)
)

This code defines only one block....I want to be able to not have to change the command name (xxxxxxx) to access the entire folder of blocks and then type in the block name (yyyyyyy) in a second window to insert it.....

Share this post


Link to post
Share on other sites
mtaussie

You could try something like this, but all of the blocks need to be in AutoCAD's support path

 

(defun c:xxxx ( / strBlockName insertpt1)
 (setq strBlockName (getstring "\nEnter Block Name: "))
 (setq insertpt1 (getpoint "\nPick Lower Left Corner of the cabinet: "))
 (if (and insertpt1 (findfile (strcat strBlockName ".dwg")))
   (command "_insert" strBlockName insertpt1 "" "" "")
   (prompt "\nBlock not found in support path! ")
 )
(princ)
)

Share this post


Link to post
Share on other sites
Skilled Warrior

Thank God someone was able to help me with this....Thank you mtaussie. I've been looking in a Visual Lisp programming book I received from an old co-worker. I was going to spend today trying to tackle DCL files and some how getting it to work with the Lisp code I already had, but this code that you have provided works perfectly. Thank you for the great help.

Share this post


Link to post
Share on other sites
KARDOLITO89

Thank you for the answer, but is there any condition for the file saved in the support path?

What is the location of the support path?

 

you could try something like this, but all of the blocks need to be in autocad's support path

 

(defun c:xxxx ( / strblockname insertpt1)
 (setq strblockname (getstring "\nenter block name: "))
 (setq insertpt1 (getpoint "\npick lower left corner of the cabinet: "))
 (if (and insertpt1 (findfile (strcat strblockname ".dwg")))
   (command "_insert" strblockname insertpt1 "" "" "")
   (prompt "\nblock not found in support path! ")
 )
(princ)
)

Share this post


Link to post
Share on other sites
BIGAL

I think your approaching this from the wrong direction, it sounds like your just using a block for every combo ie 2x4 3x4 etc it would be much better if you spent a little bit of time looking at dynamic blocks you can have 1 block with a certain style but a multitude of variations that can be just simply adjusted, at the simplest a square, click on it enter length and width. The other way is to look at lips to draw the cabinets these can be a library of a few different styles again just ask questions and its drawn. To draw something complex may be just answer 8 questions the 9th is where do you want it.

 

Have a search here for David Bethel and look at some of his images the equipment is drawn in full 3d just answering questions.

Share this post


Link to post
Share on other sites
BIGAL
Posted (edited)

Have a look at this it will draw a simple table any size its only an example it could be expanded to a full cut list dimensioned and so forth. I really do think if you have that many blocks you are doing something wrong. Automation even if you have to pay will save thousands very quickly. There are plenty here who would be able to provide a couple of freebies and a price to seriously reduce your 250,00 std dwgs dependance and time savings accuracy etc.

 

(defun drawlegs (pt1 legL legw /  )
(setq pt2 (polar pt1 0.0 legL))
(setq pt3 (polar pt2 (/ pi 2.0) legw))
(setq pt4 (polar pt3 pi legL))
(command "pline" pt1 pt2 pt3 pt4 "C")
)
(defun c:tab-legs ( / l w pt thk l1 H)
(setq oldsnap (getvar 'osmode))
(setvar 'osmode 0)
(setq l (getdist "Enter L"))
(setq w (getdist "Enter W"))
(setq thk (getdist "enter thickness"))
(setq H (getdist "Enter height"))
(setq l1 (getdist "Enter leg size"))
(setq pt (getpoint "Pick start point"))
(drawlegs pt l w)
(command "extrude" "last" "" thk)
(command "move" "L" "" (list 0.0 0.0 0.0) (list 0.0 0.0 H))
(drawlegs pt l1 l1)
(command "extrude" "last" "" H)
(setq pt (polar pt 0.0 (- l l1)))
(drawlegs pt l1 l1)
(command "extrude" "last" "" H)
(setq pt (polar pt (* pi 0.5) (- w l1)))
(drawlegs pt l1 l1)
(command "extrude" "last" "" H)
(setq pt (polar pt pi (- l l1)))
(drawlegs pt l1 l1)
(command "extrude" "last" "" H)
(command "-vpoint" '(1 1 1 ))
(setvar 'osmode oldsnap)
)
(C:legs)

 

PS just had a look and our library area etc has 777 dwgs some of these are just so old. We have 363 dwg images in our current menu's some more than others we use.

 

Post a couple of blocks that are basicly the same thing but with different sizes etc and we could comment about how hard to reproduce asking size questions.

Edited by BIGAL

Share this post


Link to post
Share on other sites
rlx

I totally agree with Bigal that cleaning up & combining blocks is the way to go... 250,000 blocks...pfff how on earth did they end up with so many. Something that may give you a little help in at least get a sort of visual overview : http://www.cadtutor.net/forum/showthread.php?95094-RlxPaste&highlight=rlxpaste

Its not a very smart insert util , but you can at least get a visual on what your dealing with by using the add folder button. Its an oldie so hope it still works...

 

 

gr. Rlx

Share this post


Link to post
Share on other sites
ronjonp

You could also try something like this .. but agreed 250,000 blocks is insane.

(defun c:foo (/ p d)
 (cond	((and (setq d (getfiled	"\nPick a block to insert: "
			(if (findfile "G:\\DRAFTERS\\Casework")
			  "G:\\DRAFTERS\\Casework"
			  (getvar 'dwgprefix)
			)
			"dwg"
			8
	      )
      )
      (setq p (getpoint "\nPick Lower Left Corner of the cabinet: "))
 )
 (command "_.insert" d p "" "" "")
)
 )
 (princ)
)

Share this post


Link to post
Share on other sites
rlx
You could also try something like this .. but agreed 250,000 blocks is insane.

(defun c:foo (/ p d)
...
)

 

 

only scenario I can think of would be a engineering company with many different clients but even then , you would still have some kind of order (else poor clients) :cry:

Share this post


Link to post
Share on other sites
BIGAL
Posted (edited)

skilled warrior its your turn now.:)

Edited by BIGAL

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×