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

Thread: Help: Update insert block lisp

  1. #1
    Member
    Join Date
    2023-03
    Posts
    19
    Login to Give a bone
    0

    Default Help: Update insert block lisp

    Hi, I use this code to insert blocks in the drawings. This code insert the block from a specific file in to AutoCAD by picking the insert point.

    I want to add an extra option

    a) pick a point for insert the block
    b) To give the point number and insert the block and this can be for multiple points (The points I use is block attributes ,look test.dwg I insert some points for example)

    for example

    Insert point ? [point / number]

    > number
    20
    enter
    44
    enter
    46
    enter
    enter (<--- for exit)


    This is the code I use

    Code:
        (Defun c:DEH ( / dt1 )
         (command "_layer" "_m" "DEH" "_c" "33" "" "")
         (setq olderr *error*
                 *error* at_err)
         (setvar "blipmode" 0)
         (setq osm (getvar "osmode"))
         (setvar "cmdecho" 0)
         (setq scl (getint "\n Set Scale (50,100,200,250,500,etc) :"))
         (setq scl1 (* scl 0.0025))
         (setq dt1 (getpoint "\n Select point to insert the block:"))
         (command "insert" "c:\\MBL\\DEH1.dwg" dt1 scl1 scl1 0)
         (setvar "cmdecho" 1)
         (setvar "blipmode" 1)
         (setvar "osmode" osm)
         (command "setvar" "clayer" "0")
        )

    Thanks
    Attached Images Attached Images
    Attached Files Attached Files

  2. #2
    Certifiable AUGI Addict tedg's Avatar
    Join Date
    2005-06
    Location
    in the upper right corner
    Posts
    3,492
    Login to Give a bone
    0

    Default Re: Help: Update insert block lisp

    The block that actually has the point number is "point"
    I'm not sure how this all works, the drawing (block) DEH1.dwg you supplied and referenced doesn't have the attributes.

    So I took a stab at your lisp with the block (named "point") and it allows you to type in a number.
    Hope that helps

    Code:
        (Defun c:DEH ( / dt1 pt1 )
         (command "_layer" "_m" "DEH" "_c" "33" "" "")
         (setq olderr *error*
                 *error* at_err)
         ;;(setvar "blipmode" 0)
         (setvar "attreq" 1)
         (setvar "attdia" 0)
         (setq osm (getvar "osmode"))
         (setvar "cmdecho" 0)
         (setq scl (getint "\n Set Scale (50,100,200,250,500,etc) :"))
         (setq scl1 (* scl 0.0025))
         (setq pt1 (getstring "\nPoint Number: "))
         (setq dt1 (getpoint "\n Select point to insert the block:"))
         (command "insert" "c:\\MBL\\point.dwg" dt1 scl1 scl1 0 pt1 "" "")
         (setvar "cmdecho" 1)
         ;;(setvar "blipmode" 1)
         (setvar "osmode" osm)
         (command "setvar" "clayer" "0")
        )

  3. #3
    Member
    Join Date
    2023-03
    Posts
    19
    Login to Give a bone
    0

    Default Re: Help: Update insert block lisp

    Hi tedg. Thanks for the reply. I test your code but is not working.

  4. #4
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,300
    Login to Give a bone
    0

    Default Re: Help: Update insert block lisp

    Don't simply say something is "not working". It doesn't help to solve the problem. Describe the problem. Give some detail, like error messages.
    C:> ED WORKING....

  5. #5
    Certifiable AUGI Addict tedg's Avatar
    Join Date
    2005-06
    Location
    in the upper right corner
    Posts
    3,492
    Login to Give a bone
    0

    Default Re: Help: Update insert block lisp

    Quote Originally Posted by mhy3sx. View Post
    Hi tedg. Thanks for the reply. I test your code but is not working.
    As I mentioned, the drawing file that contains the point number (among other attributes) is a different file than the "DEH1.dwg".

    I don't know where in your process that drawing file "Point" gets inserted but that is what you want to call for the insert (and the path to it needs to be in the routine)
    This won't work when inserting "DEH1.dwg", Im not sure if that is a different routine to insert or can add that too
    You need to put the path to "Point.dwg" in the routine and it will allow you to use it.

    So, to recap:
    you need to know the path that the Point.dwg is and
    you need that in the routine
    (They need to match wherever you have it)

    I used "c:\\MBL\\point.dwg" but you may have it somewhere else.

    As Ed mentioned, we need more information on what you're doing, what errors you're getting, and what isn't working specifically.
    Screen shots of your command line and screen would help too.
    (I also attached a copy of your "Point.dwg" to put somewhere if you don't know where it normally is in your process)
    Attached Files Attached Files
    Last edited by tedg; 2023-07-31 at 03:08 PM.

  6. #6
    Member
    Join Date
    2023-03
    Posts
    19
    Login to Give a bone
    0

    Default Re: Help: Update insert block lisp

    I ask to give the point number and insert the block and this can be for multiple points (The points I use is block attributes ,look test.dwg I insert some points for example)

    The points is allready in the drawing. In tedg code have

    Code:
    ))
         (setq pt1 (getstring "\nPoint Number: "))
         (setq dt1 (getpoint "\n Select point to insert the block:"))           ;<- what point to select, I give the number of the point to insert the DEH1.dwg
         (command "insert" "c:\\MBL\\point.dwg" dt1 scl1 scl1 0 pt1 "" "")   ;<-- I want to insert DEH1.dwg

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

    Default Re: Help: Update insert block lisp

    This means your code needs to search all of the blocks within the drawing that contain the attribute that has the Point Number specified by the user. As you want to continue to insert new blocks until you "Enter" out of the code means you will need to place all of this into a loop.
    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

  8. #8
    Certifiable AUGI Addict tedg's Avatar
    Join Date
    2005-06
    Location
    in the upper right corner
    Posts
    3,492
    Login to Give a bone
    0

    Default Re: Help: Update insert block lisp

    Quote Originally Posted by mhy3sx. View Post
    I ask to give the point number and insert the block and this can be for multiple points (The points I use is block attributes ,look test.dwg I insert some points for example)

    The points is allready in the drawing. In tedg code have
    ...
    There are prettier ways to do this, but this works based on what you provided for info.
    I commented out where it needs a path for the "point.dwg" assuming it is in the file you're working in already.
    This inserts both of those blocks, you pick the scale and then loops for numbers and pick points.

    That's all I have

    Code:
        (Defun c:DEH ( / dt1 pt1 )
         (command "_layer" "_m" "DEH" "_c" "33" "" "")
         (setq olderr *error*
                 *error* at_err)
         ;;(setvar "blipmode" 0)
         (setvar "attreq" 1)
         (setvar "attdia" 0)
         (setq osm (getvar "osmode"))
         (setvar "cmdecho" 0)
         (setq scl (getint "\n Set Scale (50,100,200,250,500,etc) :"))
         (setq scl1 (* scl 0.0025))
    (while ;<-- while lets you continue to type numbers and pick points
         (setq pt1 (getstring "\nPoint Number: "))
         (setq dt1 (getpoint "\n Select point to insert the block:"))
         ;;(command "insert" "c:\\MBL\\point.dwg" dt1 scl1 scl1 0 pt1 "" "");<--if outside the dwg
         (command "insert" "point" dt1 scl1 scl1 0 pt1 "" "");<--if inside the dwg
         (command "insert" "c:\\MBL\\DEH1.dwg" dt1 scl1 scl1 0)
    ) ;<-- end while
         (setvar "cmdecho" 1)
         ;;(setvar "blipmode" 1)
         (setvar "osmode" osm)
         (command "setvar" "clayer" "0")
        )

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

    Default Re: Help: Update insert block lisp

    Ted, I believe you are misreading the request for help.

    The user would enter the "Point number". This would be a number (actually it would be a string) in an attribute for one of the many "Point" named block insertions. Once that number associated block is found, then use the insertion of said block to insert the DEH1 block. There would not be a prompt for insertion point.

    At least that is how I would interpret the request. The request is a little more complicated than the provided code.

    It would probably be helpful to cycle through all of the points once and make an associative list between the point number found in the attribute's textstring and the associated point block. This would reduce the necessary time to go through all of the points each time the user inputs a new number.
    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

  10. #10
    Member
    Join Date
    2023-03
    Posts
    19
    Login to Give a bone
    0

    Default Re: Help: Update insert block lisp

    Opie is correct. Ted the points are allredy in the drawing, Your code insert point with givings number , not the DEH1.dwg to exist point number

Page 1 of 3 123 LastLast

Similar Threads

  1. Need a help in modification of lisp. Please update the lisp code as required.
    By brahmanandam.thadikonda762224 in forum AutoLISP
    Replies: 0
    Last Post: 2018-09-20, 04:12 AM
  2. Replies: 1
    Last Post: 2017-01-15, 12:22 AM
  3. HELP......With Insert Block Lisp From Excel File
    By CADdancer in forum AutoLISP
    Replies: 1
    Last Post: 2013-06-25, 08:47 PM
  4. Replies: 27
    Last Post: 2006-10-06, 01:04 PM
  5. Replies: 19
    Last Post: 2006-03-14, 05:06 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
  •