Jump to content

Block Insert Lisp


Skilled Warrior

Recommended Posts

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.

Link to comment
Share on other sites

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.....

Link to comment
Share on other sites

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)
)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 8 years later...

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)
)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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)
)

Link to comment
Share on other sites

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:

Link to comment
Share on other sites

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...