See the top rated post in this thread. Click here

Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 27

Thread: Insert block from pull down menu & Show outline shape

  1. #11
    All AUGI, all the time
    Join Date
    2015-10
    Location
    Belgrade, Serbia, Europe
    Posts
    564
    Login to Give a bone
    0

    Default Re: Insert block from pull down menu & Show outline shape

    Isn't this enough - without GrSnap...
    (With your version - ACAD will snap to vertex of block itself if it's nearer insertion point before attempt to snap to other entity/ies in active space causing that insert while (entmod) moves with gaps - not smoothly)... This although insert do not snap, marker is turned on like with ordinary move with turned OSNAPS and insert is placed on marker upon finishing of routine...

    Code:
    (defun blkins ( blkname / BlkSetExplodability )
    
      (defun BlkSetExplodability ( BlockName Explodability / e ed e330 e330d )
        ;second argument 0=non-Explodability 1=Explodability
        (setq e (tblobjname "BLOCK" BlockName)
              ed (entget e)
              e330 (cdr (assoc 330 ed))
              e330d (entget e330)
              e330d (subst (cons 280 Explodability) (assoc 280 e330d) e330d)
        );setq
        (entmod e330d)
      )
    
      (BlkSetExplodability blkname 1)
      (vl-cmdf "_.-INSERT" blkname "\\" 1.0 "" 0.0)
      (vl-cmdf "_.EXPLODE" "_L")
      (vl-cmdf "_.COPYBASE" "_non" (getvar 'lastpoint) "_P" "")
      (vl-cmdf "_.ERASE" "_P" "")
      (vl-cmdf "_.PASTEBLOCK" "_non" (getvar 'lastpoint))
      (vl-cmdf "_.-RENAME" "_BLOCK" (cdr (assoc 2 (entget (entlast)))) (strcat blkname "-" (rtos (getvar 'cdate) 2 6)))
      (princ)
    )

  2. #12
    Member
    Join Date
    2020-02
    Posts
    16
    Login to Give a bone
    0

    Default Re: Insert block from pull down menu & Show outline shape

    Thanks to both for your efforts.

    EDIT: This post is updated, please disregard previous content if read.

    dlanor: Post #10
    After getting error messages initially, it appears that all the Lee-Mac functions needed to be inserted after the code in post #10.
    This seems to work now.
    There are a couple of items I would like to ask about.
    (1) After the block is inserted, a selection box automatically comes up. Why does this happen?
    (2) Is there anyway to stop the block from inserting if I press Escape?

    marko_ribar: Post #11
    After running your code, the following error message comes up "; error: bad argument type: lentityp nil".
    I would like to see if this can work as well.
    Last edited by AC2076; 2020-02-12 at 02:25 AM.

  3. #13
    All AUGI, all the time
    Join Date
    2015-10
    Location
    Belgrade, Serbia, Europe
    Posts
    564
    Login to Give a bone
    0

    Default Re: Insert block from pull down menu & Show outline shape

    Here, try this snippet... Should work for both normal and dynamic blocks...

    Code:
    (defun blkins ( blkname )
      (vl-cmdf "_.-INSERT" (strcat (vl-filename-base blkname) "-" (rtos (getvar 'cdate) 2 6) "=" blkname) "\\" 1.0 "" 0.0)
      (princ)
    )
    Regards, M.R.

  4. #14
    Member
    Join Date
    2020-02
    Posts
    16
    Login to Give a bone
    0

    Default Re: Insert block from pull down menu & Show outline shape

    Hi Marko, I assume this short snippet is to be used as shown.
    Unfortunately this doesn't place the block at the cursor location, there is no hovering, etc.

  5. #15
    All AUGI, all the time
    Join Date
    2015-10
    Location
    Belgrade, Serbia, Europe
    Posts
    564
    Login to Give a bone
    0

    Default Re: Insert block from pull down menu & Show outline shape

    Firstly set OSNAPS with desired choice (type "OS" and turn some checks - for ex. "end,mid,int")...
    Then load my snippet and finally apply it with something like this :

    Code:
    (blkins "c:\\                  TESTING ROUTINES\\truss.dwg")
    Note - you must specify "\\" instead of "\" when constructing correct path-filename expression...

    HTH., M.R.

  6. #16
    Member
    Join Date
    2020-02
    Posts
    16
    Login to Give a bone
    0

    Default Re: Insert block from pull down menu & Show outline shape

    Sorry Marko you've lost me now.

  7. #17
    Active Member
    Join Date
    2015-12
    Location
    Western Europe
    Posts
    57
    Login to Give a bone
    0

    Default Re: Insert block from pull down menu & Show outline shape

    What Marco is refering to is the string you pass to the function. AutoCAD requires the escape character "" itself to be escaped in file path strings. This means paths to blocks must be constructed using "\" instead of "". Alternatively you can use the linux\unix path separator "/"

    This means "C:\temp\my.dwg" needs to be "C:\\temp\\my.dwg" or "C:/temp/my.dwg".

  8. #18
    Member
    Join Date
    2020-02
    Posts
    16
    Login to Give a bone
    0

    Default Re: Insert block from pull down menu & Show outline shape

    I am totally confused sorry.

    Firstly set OSNAPS with desired choice (type "OS" and turn some checks - for ex. "end,mid,int")...
    This is the case.

    Then load my snippet and finally apply it with something like this :
    I can't understand how to call up "blkins" again as the snippet has this already.

    Also I can't understand why you are calling up a drawing file path since this is already done in the Script file (see original post).

    Sorry but I'm basically asking you for the answer.
    Please don't think I'm not trying.

  9. #19
    Active Member
    Join Date
    2015-12
    Location
    Western Europe
    Posts
    57
    Login to Give a bone
    0

    Default Re: Insert block from pull down menu & Show outline shape

    Quote Originally Posted by AC2076 View Post
    Thanks to both for your efforts.

    EDIT: This post is updated, please disregard previous content if read.

    dlanor: Post #10
    After getting error messages initially, it appears that all the Lee-Mac functions needed to be inserted after the code in post #10.
    This seems to work now.
    There are a couple of items I would like to ask about.
    (1) After the block is inserted, a selection box automatically comes up. Why does this happen?
    (2) Is there anyway to stop the block from inserting if I press Escape?
    Yes. My apologies, I should have pointed that out.

    In answer to your 2 questions :

    1. I cannot reproduce this, but I don't know what you are passing to the blkins function. It could be something simple.

    2. This should be possible, but I'm no expert when it comes to grread. I'll have a play with it but cannot guarantee anything.

  10. #20
    Active Member
    Join Date
    2015-12
    Location
    Western Europe
    Posts
    57
    Login to Give a bone
    1

    Default Re: Insert block from pull down menu & Show outline shape

    OK. Revised code is attached, this includes the grsnap functions. I cannot work the "ESC" key in, but a left mouse button click will insert the block, and a right mouse button clickwill delete the entity.
    Attached Files Attached Files

Page 2 of 3 FirstFirst 123 LastLast

Similar Threads

  1. Double Click Pull Down Menu to Use Last Command Used from Menu
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 2
    Last Post: 2017-04-06, 01:09 PM
  2. Pull Down menu dropping custom Pull downs one by one
    By lessZmore in forum AutoCAD CUI Menus
    Replies: 1
    Last Post: 2010-09-28, 10:34 PM
  3. Pull Down Menu & CUI not communicating?
    By tiffany.amorgan in forum AutoCAD CUI Menus
    Replies: 2
    Last Post: 2007-10-05, 04:39 PM
  4. Replies: 2
    Last Post: 2007-01-09, 06:39 AM
  5. Calling an Image Tile Menu from Pull-Down Menu
    By pinckney3 in forum AutoCAD CUI Menus
    Replies: 2
    Last Post: 2006-01-06, 06:42 PM

Tags for this Thread

Posting Permissions

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