Jump to content

Looking for a custom program to Insert blocks from a cad library?


Recommended Posts

Posted

I’m going form CAD 2004 to 2008

Looking for some ideas.

I have over 500 blocks for HVAC, Electric, and Controls & Plumbing details.

Looking for an easy way to create ether Toolbars, Tool Pallets or if there is any other way.

Or having a new insert tool.

Using the insert command Dialog box preview is too small.

It would be great if there was a better insert box with larger Preview box, Description of the block and file, and a way to add your own Directories, an a browse button and a way to select what layer to insert on. CAD blocks are stored on the z server.

Can any one help me :roll:

Posted

I suppose you could compact all the library into one LISP.

 

Where I worked, we had a library of valve blocks, and I created a LISP enabling the user to type a keyword after invoking the LISP that would automatically insert the correct block into the drawing - leaving the user to position it as necessary.

Posted

Below is the code that I used when inserting my valve library - let me know if you are interested and I could modify the LISP accordingly for you :)

 

(defun c:valv (/ *error* oldVars varLst oldos oldlay vchx ln1 pt1 valvno ln1ent ang1 block1 c1)

   (defun *error*(msg)
   (if oldVars
       (mapcar 'setvar varLst  oldVars)
   ); end if
   (princ "\nError or Esc pressed... Exit Program. ")
   (princ)
   ); end of *error*
 
       (setq varLst(list "CMDECHO" "OSMODE" "CLAYER" "DIMSCALE")
         oldVars(mapcar 'getvar varLst)
         ); end setq 

   (setvar "cmdecho" 0)
   (princ "\nInitialising... ")
   (setq oldos (getvar "osmode"))
   (setq oldlay (getvar "clayer"))
   (initget 1 "Ball Butterfly Diaphragm Gate Globe")
   (setq vchx (getkword "\nSpecify Valve Type [bAll/BUtterfly/Diaphragm/GAte/GLobe]: "))
   (while
       (and
           (/= (setq ln1 (entsel "\nSelect Line for Valve: ")) nil)
           (/= (setq pt1 (getpoint "\nSelect Point for Valve: ")) nil)
           (/= (setq valvno (getstring "\nType Valve Number: ")) "")
       ) ; end and
       (setq ln1ent (entget (car ln1)))
       (setq ang1 
           (angle
               (cdr (assoc 10 ln1ent))
               (cdr (assoc 11 ln1ent))
           ) ; end angle
       ) ; end setq
       (setvar "clayer" "4")
       (setvar "osmode" 0)
       (cond
           (
               (= vchx "Gate")
               (command "_.insert"
                   "C:\\Users\\Lee Mac\\Documents\\Valves\\GATE VALVE.dwg"
                   pt1
                   ""
                   ""
                   (rtd ang1)
                   valvno
               ) ; end insert
               (setq block1 (entlast))
           ) ; end condition 1
           (
               (= vchx "Globe")
               (command "_.insert"
                   "C:\\Users\\Lee Mac\\Documents\\Valves\\GLOBE VALVE.dwg"
                   pt1
                   ""
                   ""
                   (rtd ang1)
                   valvno
               ) ; end insert
               (setq block1 (entlast))
           ) ; end condition 2
           (
               (= vchx "Ball")
               (command "_.insert"
                   "C:\\Users\\Lee Mac\\Documents\\Valves\\BALL VALVE.dwg"
                   pt1
                   ""
                   ""
                   (rtd ang1)
                   valvno
               ) ; end insert
               (setq block1 (entlast))
           ) ; end condition 3
           (
               (= vchx "Butterfly")
               (command "_.insert"
                   "C:\\Users\\Lee Mac\\Documents\\Valves\\BUTTERFLY VALVE.dwg"
                   pt1
                   ""
                   ""
                   (rtd ang1)
                   valvno
               ) ; end insert
               (setq block1 (entlast))
           ) ; end condition 4
           (
               (= vchx "Diaphragm")
               (command "_.insert"
                   "C:\\Users\\Lee Mac\\Documents\\Valves\\DIAPHRAGM VALVE.dwg"
                   pt1
                   ""
                   ""
                   (rtd ang1)
                   valvno
               ) ; end insert
               (setq block1 (entlast))
           ) ; end condition 5
       ) ; end cond

;        ***TRIM***

       (command "_circle"
           pt1
           "3"
       ) ; end circle
       (setq c1 (entlast))
   (setq rad 1.2)
   (entdel block1)
       (command "zoom" "window"
       (polar pt1 (* pi 1.25) rad )
       (polar pt1 (* pi 0.25) rad )
   )
   (command "trim" c1 "" pt1 "")
       (command "_zoom"
           "P"
       ) ; end zoom
       (entdel block1)
   (entdel c1)

;    *** Rotation of Valve ***
   
   (satisfy)

       (setvar "clayer" oldlay)
       (setvar "osmode" oldos)
   ) ; end while
   (setvar "cmdecho" 1)
   (prompt "\nFunction Complete. ")
   (princ)
) ; end program

(defun satisfy (/ ans1)
   (initget "Yes No")
   (setq ans1 (getkword "\nRotate Valve? [Yes/No] <No>: "))
   (if
       (= ans1 "Yes")
       (command "_rotate" block1 "" pt1 "180.0" )
   ) ; end if
) ; end program

(defun rtd (a)
   (* 180.0 (/ a pi))
) ; end program

Hope this helps :P

Posted

Here is what I have been using. I just updated it for my standrad library the other day. Here is the call:

 

(STDLIB_BLOCK_INSERT "C:/Acad ToolBOX/Block Library/00 - Annotation/ViewCalloutMain.dwg" "0" 48.0 0.0 nil)

 

(watch word wrap)

 

it breaks down to this:

= Full path included *Must be included

= Must be in the drawing already or it will default to current layer"

= Scale to be inserted on if "nil" defaults to 1

= Rotation angle of block if "nil" it will allow on screen selection

= If "T" it will explode the block once inserted If "nil" no explode

STDLIB_InsertBlock.lsp

Posted

Lee,

I was looking for something that would come with a dialog box with a preview window.

And to be able to browse and to have priests set directories to choose from.

Any program at this point would be a good start.

I have the program Ksoft DCL & AutoLisp Generator.

It can create DCL and Lisp routines, but the files it generates are incomplete or are still scratching the surface and trying to learn Lisp.

It's seems that you do need to know Lisp just to complete the files.

I’m still learning Lisp as I go, because I just don't have the time to take classes.

I've got enough on my plate.

I would like to try your program and see how well it works.

But I’m going to program using Ksoft and see if I can find someone that will complete the files for me.

Thanks

Posted

Hi,

 

My program does not come with a dialog box, but works from a user selecting a keyword from the command prompt - this may be ok for now, but with the amount of blocks you are dealing with, it may not suffice.

 

To give you an example of how my program functions, see the attached video.

Block Insertor.zip

Posted

Question

Still learning Lisp. I have come across Lisp routines in the past but I've always wanted to use, but could not figure out what the executable command was and where to find it in a lsp, VBA.

And what is dvb format?

I’m going to start making time to learn lisp.

Is there a Free web site that I can start learning the basics for Lisp, VB and VBA?

Posted

You can do it all with menu's and have a image appear automaticfly using slides or a slide library (group of slides) you can pick via either image or by name you do not have to write any code other than menu code which is really easy

 

***MENUGROUP=COGGSTDS
***POP1
**CADLIB
[LIBRARY]
[->Stddwgs]
[TRENCH]$I=COGGSTDS.TRENCH $I=*
[PIPES]$I=COGGSTDS.PIPES $I=*
[PITS]$I=COGGSTDS.PITS $I=*
[KERBS]$I=COGGSTDS.KERBS $I=*
[ROADX]$I=COGGSTDS.ROADX $I=*

***image
**TRENCH
[TRENCH]
[COGGSLD(CGG101,KERB]^C^C(openblk "S:/ACADSTDS/CIVIL STANDARDS/CGG101")
[COGGSLD(CGG102,NATURE)]^C^C(openblk "S:/ACADSTDS/CIVIL STANDARDS/CGG102")

**PIPES
[PIPES]
[COGGSLD(SD201,SUBSOIL)]^C^C(openblk "S:/ACADSTDS/CIVIL STANDARDS/CGG201")
[COGGSLD(SD202,FLUSHOUT)]^C^C(openblk "S:/ACADSTDS/CIVIL STANDARDS/CGG202")

blocks.JPG

Posted

I Have this code which inserts the block for you at the correct size. I could make some minor changes to it and you would be able to use say a toolbar / menu and set commands for each different block and simply set the button to run that command. It has worked fine for me and im running about 20-30 blocks from mine.

 

As to where to find the command in a lisp routine. It would look something like this c:"command would be here"

 

This is the code. I would need to make some changes to it for you if you wanted to use it.

 

;---DETAIL BUBBLE---
(defun c:insert-detbub-block (/ layerset)
(setq layerset (getvar "clayer"))
(setvar "clayer" "35")
(setq scaleset(/ 1 (getvar "cannoscalevalue")))
(setvar "ATTDIA" 0)
(setq ins-pt (getpoint "\nSelect Insertion Point: <0,0>"))
(if (= nil ins-pt) (setq ins-pt (list 805 553)) )
(command "-insert" "detail bubble" ins-pt scaleset scaleset "0")
(command "explode" (entlast))
(setvar "ATTDIA" 1)
(setvar "clayer" layerset)
(princ)
) ;defun

  • 11 years later...
Posted (edited)
On 12/14/2008 at 2:04 AM, Lee Mac said:

Below is the code that I used when inserting my valve library - let me know if you are interested and I could modify the LISP accordingly for you :)

 

 


(defun c:valv (/ *error* oldVars varLst oldos oldlay vchx ln1 pt1 valvno ln1ent ang1 block1 c1)

   (defun *error*(msg)
   (if oldVars
       (mapcar 'setvar varLst  oldVars)
   ); end if
   (princ "\nError or Esc pressed... Exit Program. ")
   (princ)
   ); end of *error*
 
       (setq varLst(list "CMDECHO" "OSMODE" "CLAYER" "DIMSCALE")
         oldVars(mapcar 'getvar varLst)
         ); end setq 

   (setvar "cmdecho" 0)
   (princ "\nInitialising... ")
   (setq oldos (getvar "osmode"))
   (setq oldlay (getvar "clayer"))
   (initget 1 "Ball Butterfly Diaphragm Gate Globe")
   (setq vchx (getkword "\nSpecify Valve Type [bAll/BUtterfly/Diaphragm/GAte/GLobe]: "))
   (while
       (and
           (/= (setq ln1 (entsel "\nSelect Line for Valve: ")) nil)
           (/= (setq pt1 (getpoint "\nSelect Point for Valve: ")) nil)
           (/= (setq valvno (getstring "\nType Valve Number: ")) "")
       ) ; end and
       (setq ln1ent (entget (car ln1)))
       (setq ang1 
           (angle
               (cdr (assoc 10 ln1ent))
               (cdr (assoc 11 ln1ent))
           ) ; end angle
       ) ; end setq
       (setvar "clayer" "4")
       (setvar "osmode" 0)
       (cond
           (
               (= vchx "Gate")
               (command "_.insert"
                   "C:\\Users\\Lee Mac\\Documents\\Valves\\GATE VALVE.dwg"
                   pt1
                   ""
                   ""
                   (rtd ang1)
                   valvno
               ) ; end insert
               (setq block1 (entlast))
           ) ; end condition 1
           (
               (= vchx "Globe")
               (command "_.insert"
                   "C:\\Users\\Lee Mac\\Documents\\Valves\\GLOBE VALVE.dwg"
                   pt1
                   ""
                   ""
                   (rtd ang1)
                   valvno
               ) ; end insert
               (setq block1 (entlast))
           ) ; end condition 2
           (
               (= vchx "Ball")
               (command "_.insert"
                   "C:\\Users\\Lee Mac\\Documents\\Valves\\BALL VALVE.dwg"
                   pt1
                   ""
                   ""
                   (rtd ang1)
                   valvno
               ) ; end insert
               (setq block1 (entlast))
           ) ; end condition 3
           (
               (= vchx "Butterfly")
               (command "_.insert"
                   "C:\\Users\\Lee Mac\\Documents\\Valves\\BUTTERFLY VALVE.dwg"
                   pt1
                   ""
                   ""
                   (rtd ang1)
                   valvno
               ) ; end insert
               (setq block1 (entlast))
           ) ; end condition 4
           (
               (= vchx "Diaphragm")
               (command "_.insert"
                   "C:\\Users\\Lee Mac\\Documents\\Valves\\DIAPHRAGM VALVE.dwg"
                   pt1
                   ""
                   ""
                   (rtd ang1)
                   valvno
               ) ; end insert
               (setq block1 (entlast))
           ) ; end condition 5
       ) ; end cond

;        ***TRIM***

       (command "_circle"
           pt1
           "3"
       ) ; end circle
       (setq c1 (entlast))
   (setq rad 1.2)
   (entdel block1)
       (command "zoom" "window"
       (polar pt1 (* pi 1.25) rad )
       (polar pt1 (* pi 0.25) rad )
   )
   (command "trim" c1 "" pt1 "")
       (command "_zoom"
           "P"
       ) ; end zoom
       (entdel block1)
   (entdel c1)

;    *** Rotation of Valve ***
   
   (satisfy)

       (setvar "clayer" oldlay)
       (setvar "osmode" oldos)
   ) ; end while
   (setvar "cmdecho" 1)
   (prompt "\nFunction Complete. ")
   (princ)
) ; end program

(defun satisfy (/ ans1)
   (initget "Yes No")
   (setq ans1 (getkword "\nRotate Valve? [Yes/No] <No>: "))
   (if
       (= ans1 "Yes")
       (command "_rotate" block1 "" pt1 "180.0" )
   ) ; end if
) ; end program

(defun rtd (a)
   (* 180.0 (/ a pi))
) ; end program
 

 

Hope this helps :P

Hi dear lee

Im gonna use this code and i am tried it and apparently  it works with valv library, is it possible share it .?

Edited by hosyn
Posted

… probably not - Lee said (12 years ago....) that the LISP was one at a company he used to work at... and even so would be unlikely to share what could be propriety company drawings.

 

If you look at the code you should see the file paths - change these to your own drawing library and use file names for the blocks that you want to use. 

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