See the top rated post in this thread. Click here

Page 1 of 3 123 LastLast
Results 1 to 10 of 27

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

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

    Default Insert block from pull down menu & Show outline shape

    I have a custom menu which inserts steel sections as blocks. This is done with an MNU file, loaded using a SCR (script) file.

    There is one CAD file for each steel section. And all drawings, MNU file and SCR file are all placed in one folder.

    Another functionality was introduced ... to have unique block names, so an LSP file is created which tags on the Date to the block name to the nearest second. Note this was set to auto load.

    See attached files. If testing, place in C drive in a new folder called "Folder1". Note that the script file could not be attached, see code below.

    There is one more functionality needed. When a section is chosen from the menu, I would like to see an outline of the section.

    In the menu I have Universal Beams and Universal Columns. For testing purposes, the Universal Beams are inserted using the LSP code, and this is where I'd like to see the outline. The Universal Columns are added without the LSP code ... and you can see the outline ... however in this instance the block names would not be unique.


    SCRIPT FILE

    Code:
    (if (and (not (findfile "TEST.mnu"))
    (findfile "C:\\Folder1\\POP13 Test\\TEST.mnu")
    )
    (setenv "ACAD" (strcat (getenv "ACAD") "C:\\Folder1\\POP13 Test"))
    )
    (command "._MENULOAD" "TEST.mnu")
    (menucmd "P13=+TEST.CTOPopTEST")
    Attached Files Attached Files

  2. #2
    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. Has anyone seen this post?

  3. #3
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,106
    Login to Give a bone
    0

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

    Yes. Some have seen this post. Getting an outline of the section may require a different programming language.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  4. #4
    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 for responding. What kind of programming language is required? Do I have to start from scratch again?
    I noticed you used the term "may". I would prefer to continue with LISP, so if there are any examples on the web with a similar scenario, could you please send a link.

  5. #5
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    0

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

    That's a big ask for an antique MNU file that wasn't designed to work with images at all.
    Have you considered adding a dialog box to that lisp or using a Tool Palette, a Ribbon panel or an Image Tile Menu?

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

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

    Tom, thanks for responding. The MNU file was created a long time ago and it's only now that I'm utilising it.
    I know nothing about the other options, but if you can direct me to how each one is done, that would be appreciated ... in the form of an example if possible.

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

    This is a crude re-work of your code that utilises grread and entmod to achieve what you want, however because of the grread there are no snaps. It should be possible to rework this again using Lee Mac's GRSNAP http://www.lee-mac.com/grsnap.html

    Code:
    (defun blkins (blkname) ;the name of the program or function must be defined in the first statement
      (command "-INSERT" blkname (list 0. 0. 0.) 1 "" 0) ;"1" is the scale, "0" is the rotation
      (setq ent (entlast) e_lst (entget ent))
      (setvar 'osmode 1)
      (while (= (car (setq gr (grread T))) 5)
        (princ "\rInsertion Point : ")
        (entmod (subst (cons 10 (cadr gr)) (assoc 10 e_lst) e_lst))
      )
      (command "-rename" "block" blkname  (strcat blkname "-" (rtos (getvar "cdate") 2 6))) ; rtos: Converts a number into a string     strcat: Returns a string that is the concatenation of multiple strings 
    )

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

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

    Much appreciate the input dlanor.
    It works as suggested.
    I will now consider adding the snap capability.
    Thanks.

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

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

    This appears difficult.
    I've tried the following, aiming to combine dlanor's code and Lee Mac's demo 1 in the link provided. The hybrid shown below doesn't work but I wouldn't know where to go from here.
    I'm using the Snap function from Lee Mac and placing "LM:grsnap:snapfunction" below and in the same LISP file. I don't know if this is correct syntax in LISP.



    Code:
    (defun blkins (blkname) ;the name of the program or function must be defined in the first statement
      (command "-INSERT" blkname (list 0. 0. 0.) 1 "" 0) ;"1" is the scale, "0" is the rotation
      (setq ent (entlast) e_lst (entget ent)
        	osf (LM:grsnap:snapfunction)
      	    osm (getvar 'osmode)
      	)
      (setvar 'osmode 1)
      (while (= (car (setq gr (grread T))) 5)  ; grread: used to have a dynamic display while dragging the cursor position.
    
    (princ "\nPick point: ")
        (while (= 5 (car (setq grr (grread t 15 0))))
            (redraw)
            (osf (cadr grr) osm)
        )
        (if (listp (cadr grr))
            (entmake (list '(0 . "POINT") (cons 10 (trans (osf (cadr grr) osm) 1 0))))
        )
        (redraw) (princ)
    
    
        (entmod (subst (cons 10 (cadr gr)) (assoc 10 e_lst) e_lst))
      )
      (command "-rename" "block" blkname  (strcat blkname "-" (rtos (getvar "cdate") 2 6))) ; rtos: Converts a number into a string     strcat: Returns a string that is the concatenation of multiple strings 
    )
    
    (defun LM:grsnap:snapfunction ( )
    ;etc.
    ;etc.

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

    Try this version. Your logic was a bit out. The correct osmode needs to be set before the function is called or before the first (setq)

    Code:
    (defun blkins (blkname) ;the name of the program or function must be defined in the first statement
      (command "-INSERT" blkname (list 0. 0. 0.) 1 "" 0) ;"1" is the scale, "0" is the rotation
      (setq ent (entlast) e_lst (entget ent)
            osf (LM:grsnap:snapfunction)
            osm (getvar 'osmode)
        )
      (while (= (car (setq grr (grread T))) 5)  ; grread: used to have a dynamic display while dragging the cursor position.
        (princ "\nPick point: ")
        (redraw)
        (entmod (subst (cons 10 (trans (osf (cadr grr) osm) 1 0)) (assoc 10 e_lst) e_lst))
      )
      (command "regenall")
      (command "-rename" "block" blkname  (strcat blkname "-" (rtos (getvar "cdate") 2 6))) ; rtos: Converts a number into a string     strcat: Returns a string that is the concatenation of multiple strings 
    )

Page 1 of 3 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
  •