Block Insert Error

Discussion in 'AutoCAD' started by stck2mlon, Feb 16, 2005.

  1. stck2mlon

    stck2mlon Guest

    Hey Gang,

    I get an error at the "ntplc" getpoint section. Any help would be great appreciated!!!

    (Prompt "\n Enter linelist1 to start this program.")

    (defun C:linelist1 ()
    (setq file nil)
    (setq file2 nil)
    (setq line1 " ")
    (setq space1 " ")
    (setq comm1 " ")
    (setq comm2 " ")
    (setq prec (getvar "luprec"))
    (setvar "luprec" 0)
    (setq oldecho (getvar "cmdecho"))
    ;
    ; (setvar "CMDECHO" 0)
    (setq object1 (entsel "\nSelect Center Line of Street to get length of:\n"))
    (COMMAND "LIST" object1)
    (setvar "CMDECHO" 1)
    (setq lgth (getvar "Length"));This is to get the length of the line

    (setq dcl_id (load_dialog "linelist1.dcl")) ;load dialog
    (if (not (new_dialog "linelist1" dcl_id) ;test for dialog
    ) ;end not
    (exit) ;exit if no dialog
    ) ;end if

    (start_list "sqfoot1") ;start the list box
    (mapcar 'add_list sqfeet3) ;fill the list box
    (end_list) ;end list

    (mode_tile "Line_Lgth" 0) ;enable edit box
    (mode_tile "comment1" 0) ;enable edit box
    (mode_tile "comment2" 0) ;enable edit box
    (mode_tile "comment3" 0) ;enable edit box


    (action_tile "Line_Lgth" "(setq llgth $value)") ;store size other
    (action_tile "comment1" "(setq comm1 $value)") ;store project
    (action_tile "comment2" "(setq comm2 $value)") ;store comments
    (action_tile "comment3" "(setq comm3 $value)") ;store comments

    (start_dialog) ;start dialog
    (unload_dialog dcl_id) ;unload

    (setq clay (getvar "clayer"))


    (Setvar "ATTDIA" 10)
    (setq ntplc (getpoint "\nPick the location for the information note"))
    (command ".INSERT" "f:/cadlib/symbolsr2002/linelist1.dwg" ntplc 1 1 0 spacelbl spacenme sqfeet4 comm1 comm2 comm3)
    (setvar "clayer" clay)
    (setvar "CMDECHO" 1)
    (Setvar "luprec" 4)
    (princ)
    );defun
     
    stck2mlon, Feb 16, 2005
    #1
  2. stck2mlon

    BillZ Guest

    What kind of "error".


    Bill
     
    BillZ, Feb 16, 2005
    #2
  3. stck2mlon

    ecable Guest

    setvar "attdia" either 1 or 0 can not be 10
     
    ecable, Feb 16, 2005
    #3
  4. stck2mlon

    stck2mlon Guest

    I get the following

    Command: linelist1

    Select Center Line of Street to get length of:

    Pick the location for the information note
    Select objects: .INSERT

    *Invalid selection*
    Expects a point or Window/Last/Crossing/BOX/ALL/Fence/WPolygon/CPolygon/Group
     
    stck2mlon, Feb 16, 2005
    #4
  5. stck2mlon

    BillZ Guest

    I think what's happening is that the list command is looking for an entity name.

    You have:
    (setq object1 (entsel "\nSelect Center Line of Street to get length of:\n"))
    (COMMAND "LIST" object1)

    Try:
    (setq object1 (car (entsel "\nSelect Center Line of Street to get length of:\n")))
    (COMMAND "LIST" object1)

    Bill
     
    BillZ, Feb 16, 2005
    #5
  6. stck2mlon

    BillZ Guest

    This will have to be changed too.

    (command "list" object1)

    To:

    (command "list" object1 "")

    Bill
     
    BillZ, Feb 16, 2005
    #6
  7. stck2mlon

    stck2mlon Guest

    What am I missing to get the length to appear in the textbox? Thanks again for all of your help.
     
    stck2mlon, Feb 16, 2005
    #7
  8. stck2mlon

    BillZ Guest

    I noticed that you are using (getvar "Length") a ficticious variable. :)

    What you need is use the object1 entity list to get the length.
    Add this to your code after picking the line:

    (setq elist (entget object1))

    This will return an entity list that looks like this:

    ((-1 . <Entity name: 7ef98e98>) (0 . "LINE") (330 . <Entity name: 7ef98cf8>) (5
    "8B") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (100 .
    "AcDbLine") (10 22.8137 8.25955 0.0) (11 9.49353 16.3148 0.0) (210 0.0 0.0 1.0))

    Now assuming that this will always be a line entity, add this to you code.

    (if (= (cdr (assoc 0 elist)) "LINE")
    (setq p1 (cdr (assoc 10 elist))
    p2 (cdr (assoc 11 elist))
    lgth (distance p1 p2)))

    Now the vaiable lgth will contain the length of the line.

    Remeber to convert the real to an ascii before you set_tile it to your dialog as dialogs require a string value.

    (rtos 15.234 2 2) returns "15.23"

    HTH

    Bill
     
    BillZ, Feb 16, 2005
    #8
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.