Results 1 to 10 of 10

Thread: Macro string for inserting block?

  1. #1
    Member
    Join Date
    2008-02
    Posts
    43
    Login to Give a bone
    0

    Talking Macro string for inserting block?

    Can anyone help me with writing a macro string for inserting a block and have it delete automatically after I insert it.

    This is where my file is located:

    S:\2006 Standards\Blocks\x-file.dwg


    Also how do I type in a space between two words in the command line when I hit the space bar in the command line it act as the enter button and cannot finish my comman string? lol

  2. #2
    All AUGI, all the time Mlabell's Avatar
    Join Date
    2004-12
    Location
    Toledo, OH
    Posts
    513
    Login to Give a bone
    0

    Default Re: Macro string for inserting block?

    What do you want to delete? The block i.e a purge? Kind of unsure what you are looking for. Also are you looking for the user to enter in parameters for the insertion? Technically you should just drag the block from windows explorer onto a tool palette. But a macro can be delivered. Have you tried also searching the AutoCAD help, there is a lot of information to gain there.

  3. #3
    Member
    Join Date
    2008-02
    Posts
    43
    Login to Give a bone
    0

    Default Re: Macro string for inserting block?

    I'm simply looking to make a tool bar button so i can insert a blank drawing in my files and bam!.............. have all my layers in need. I guess deleting the drawing I insert is not a big deal since it would be blank.

  4. #4
    Certified AUGI Addict jaberwok's Avatar
    Join Date
    2000-12
    Location
    0,0,0 The Origin
    Posts
    8,570
    Login to Give a bone
    0

    Default Re: Macro string for inserting block?

    Start to insert the block, pick the insertion point then ESCape out of the command. All table entries (like layers) will be inserted but not the block.

  5. #5
    Member
    Join Date
    2008-02
    Posts
    43
    Login to Give a bone
    0

    Default Re: Macro string for inserting block?

    Quote Originally Posted by jaberwok View Post
    Start to insert the block, pick the insertion point then ESCape out of the command. All table entries (like layers) will be inserted but not the block.
    yes i understand that inserting then cancelling out of the command...........how do I write the marco for my toolbar button??? anyone......I've tried but I cannot get it to work

  6. #6
    AUGI Addict jpaulsen's Avatar
    Join Date
    2002-04
    Location
    Colorado
    Posts
    2,020
    Login to Give a bone
    0

    Default Re: Macro string for inserting block?

    I just tried writing a script today to insert and redefine a block. I could not figure out how to get it to work with a space in the path. Usually if you enclose the path in quotes it works but not in a a script. CUI macros are very similar to scripts so I assume you can;t get it to work either.

    If you don't have spaces try something like:

    ^C^C-insert;c:/test/mh;0,0,0;1;1;0;erase;(ssget "x" '((2 . "MH")));;

    Just make sure your current layer is not locked because it won't be able to erase the block. And make sure you don't have any other blocks in the drawing with the same because they will be be erased.

  7. #7
    Active Member
    Join Date
    2007-11
    Posts
    68
    Login to Give a bone
    0

    Post Re: Macro string for inserting block?

    Another option is to make a lisp like this

    (defun c:addlayers()
    (command
    "-layer" "m" "0.15 (grey)" "colour" "8" "" ""
    "-layer" "m" "0.18" "colour" "Magenta" "" ""
    "-layer" "m" "0.25" "colour" "RED" "" ""
    "-layer" "m" "0.35" "colour" "YELLOW" "" ""
    "-STYLE" "ARIAL" "ARIAL.TFF" "" "" "" "" ""
    ) (princ))

    Simple yet effective. I use it more often then id like to admit. I also added on the last line a text string so you can add a text style as well. The only issue with this is it does take a lot to set up and you may need to set up somthing to add your line types first.

    The addvantage of this is you dont use any screen space by adding another button and you can use it on any PC in the office or down the street.

  8. #8
    Certified AUGI Addict cadtag's Avatar
    Join Date
    2000-12
    Location
    Cairo - no, not Illinois
    Posts
    5,069
    Login to Give a bone
    0

    Default Re: Macro string for inserting block?

    Quote Originally Posted by Kal_digital View Post
    Can anyone help me with writing a macro string for inserting a block and have it delete automatically after I insert it.

    This is where my file is located:

    S:\2006 Standards\Blocks\x-file.dwg


    Also how do I type in a space between two words in the command line when I hit the space bar in the command line it act as the enter button and cannot finish my comman string? lol

    As the last command in your Macro, use ERASE (entlast) to remove the last entity on the drawing, which ought to be your inserted block.

    To use spaces, try enclosing the whole thing in double quotes, e.g. "S:\2006 Standards\Blocks\x-file.dwg"

  9. #9
    100 Club
    Join Date
    2007-10
    Location
    Orlando, FL
    Posts
    118
    Login to Give a bone
    0

    Default Re: Macro string for inserting block?

    A space is read as an enter command in a macro.

    To call a file with spaces, I found wildcard characters work well for me.

    Try

    S://2006*/Blocks/x-file.dwg

    Edit: I'm not sure which way the slashes should go.

  10. #10
    Woo! Hoo! my 1st post
    Join Date
    2014-10
    Posts
    1
    Login to Give a bone
    0

    Default Re: Macro string for inserting block?

    Quote Originally Posted by S_Newton View Post
    A space is read as an enter command in a macro.

    To call a file with spaces, I found wildcard characters work well for me.

    Try

    S://2006*/Blocks/x-file.dwg

    Edit: I'm not sure which way the slashes should go.
    ",THANK YOU SO MUCH @S_Newton. I was trying to figure out how to add a layer named "Gas Line" to group filter "Energy Source(s)" using script. I had to create the layers before I created the group filters, the quotations worked for any of the layers that contained spaces, but when I made group filters and then specified layers I wanted each filter to have, the layers with spaces didn't work with quotations; but after I saw your post, I added an asterisk (*) between the words and it worked! THANK YOU!

    (This was for AutoCAD 2015)

Similar Threads

  1. Select Block with Name Matching a String
    By harilalmn in forum AutoLISP
    Replies: 6
    Last Post: 2010-09-22, 11:50 AM
  2. inserting a block using a macro (diouble post)
    By treese in forum AutoCAD Customization
    Replies: 1
    Last Post: 2008-02-06, 09:12 PM
  3. Replies: 9
    Last Post: 2006-08-24, 09:29 PM
  4. Search block name for string to be set as variable value
    By montana.fox in forum VBA/COM Interop
    Replies: 5
    Last Post: 2006-02-17, 08:07 PM
  5. Add block to frame text string
    By cblendermann.91943 in forum AutoLISP
    Replies: 2
    Last Post: 2005-09-01, 07:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •