Insert a specific Block

Hi everyone,

I am trying to create a tool as a button to enable me to insert a simple block into a drawing, without having to search or type in the file name every time.

Any help from some of you pro's out there would be greatly appreciated!!!

The file is attached.

Thanks

Comments

  • Hi I use this lisp.

    (defun blins ( fpath / )
    (setvar "expert" 5)
    (command ".insert" fpath pause 1 1 pause "expert" 0 "regenall"))
    ;eof

    Then at the command line

    (blins"X:\\EGAB\\ritningar\\blocks\\termh.dwg")

    Good luck

    Patrik

  • Another little tip is that I've put my scripts and menus  in ...appdata/roaming/bricsys/scripts outside the V12 ,V13 map .This way I dont have to redo all my settings with every version, it will work automatically.    Patrik

  • Hi Patrik,

    Thanks for your answer, but lisp creation is still new to me. Could you run me through the process, and if it's not to much to ask, a basic explanation of some of the terms used.

  • Hi Rowan,

    If you have V12/V13 you could try using the Toolpalette (._TOOLPALETTES). This offers a non-programming method to do what you want. The following blog posts may be useful to you:

    Working with Blocks
    Aligning Blocks using drawing explorer
    Adding commands to the toolpalette

    Regards,

    Jason Bourhill

    CAD Concepts


  • to help with my question, the exact file path is:

    C:\SC\IDENTLOTNO.DWG

    I noticed in the lisp you wrote, the use of forward slash  "   /   " instead of back slash "   \    ". will this effect the lisp file when writing in the file path for the Block?

  • Hi,

    after a Bit of playing around, I came up with this command when adding a new tool.

    ^c^c_-insert;"C:\SC\IDENTLOTNO.dwg";N;\1;1;0;

    ^c^c (Esc Esc)

    _ (For usability in non-english versions)

    -insert (Insert command without opening dialog box)

    ; (Enter)

    "C:\SC\IDENTLOTNO.dwg" (Block file name & Path)

    ; (Enter)

    N (No to asking to redefine block)

    ; (Enter)

    \ (Wait for user entry to select position of block)

    1 (X Scale)

    ; (Enter)

    1 (Y Scale)

    ; (Enter)

    0 (Rotation angle)

    ; (Enter)

    It works fine but my next question is:

    How do I make the block automatically explode on insertion?

    Thanks,

    Rowan

  • Use an asteriks in front of the block name ...
    ^c^c_-insert;"*C:\SC\IDENTLOTNO.dwg";N;\1;1;0;
  • The things you learn , thanks Torsten.

    Patrik

  • ??  To get your stuff to work I had to type   ^c^c_-insert;"*X:\EGAB\ritningar\blocks\termh.dwg";N;\;0

    Patrik

  • Patrik,

    I think you will find that this is because you are exploding the block, and because of this the command option changes to only allow you to do equal scaling. Unequal scaling is only available if you don't explode.

    A lot of commands change in this way. I usually test on the command line first. To do this you may need to:
    • place a - (minus) sign in front of the comand, such as with _-INSERT.
    • Turn CMDDIA off
    • Turn FILEDIA off
    Note: In some cases when a file is asked for from the command line you can invoke a file dialogue by typing in ~ (tilda). Saves on typing

    Regards,

    Jason Bourhill

    CAD Concepts


  • The new code is as follows:

    ^c^c_-insert;*C:/SC/IDENTLOTNO.dwg;\1;0;.

    As jason said, I discovered that exploding means uniform scaling is used, hence the extra '1' I had at the end was for the rotation angle, and the '0' became redundant. Thanks everyone!!! :)

  • Rowan,

    you can also add the folder containing the blocks you want to use to your Support File Search Path (_SRCHPATH), you can do this from  _SETIINGS. This avoids having to specify a path on your toolbar/menu i.e. ^c^c_-insert;*C:/SC/IDENTLOTNO.dwg;\1;0; would change to ^c^c_-insert;*IDENTLOTNO.dwg;\1;0;. This makes it easier to update should the name of your folder change. No need to re-edit the menu, just update your _SRCHPATH.

    If your customising, it also pays to create your own partial CUI, rather than add it to the default.cui. You will see a number of posts in this forum where people have lost their customisation when installing a newer version of Bricscad. Hate to see all your hard won work go to waste.

    Regards,

    Jason Bourhill

    CAD Concepts


This discussion has been closed.