See the top rated post in this thread. Click here

Results 1 to 2 of 2

Thread: Selecting text from a pop-up window and pasting it on the screen

  1. #1
    The Silent Type
    Join Date
    2024-03
    Posts
    1
    Login to Give a bone
    0

    Default Selecting text from a pop-up window and pasting it on the screen

    Hello, I have a lisp code that I have been working on and I have brought it to a certain stage. However, I am having a problem at one point.
    In this lisp code, I have a product list with my purpose defined. When the code runs, my product list is listed in the pop-up window. And I choose what I want and paste it to the places I specify on the screen. However, my product list can be up to 500 items, so I created a search button in the popup window. The button works, but it is based on the line number I choose, not the product name I choose, and it writes the product on this line number in the general list to the screen. I need support on how to overcome this problem.


    Code:
    ; main command
    (defun C:prdef (/ dcl_id product_list product filter_list pt index)
      (create-layer "00-Equipment List" 3) ; Number 3 is used for green color
      (setq product_list '("Product-1" "Product-2" "Product-3" "Product-4" "Product-5" "Product-6" "Product-7" "Product-8" "Product-9" "Product-10" "Product-11" "Product-12" "Product-13" "Product-14"))
      (setq dcl_id (load_dialog "product_select.dcl"))
      (if (not (new_dialog "product_select" dcl_id))
        (exit)
      )
      (start_list "product_list")
      (mapcar 'add_list product_list)
      (end_list)
      (action_tile "search_box" "(progn (setq filter_text $value) (update_list filter_text))")
      (action_tile "product_list" "(setq product (nth (atoi $value) product_list))") ; 
      (action_tile "ok" "(done_dialog)")
      (action_tile "search_button" "(update_list filter_text)") ; 
      (start_dialog)
      (unload_dialog dcl_id)
      (initget 1)
      (while (setq pt (getpoint "\nChoose a location (exit with ESC): "))
        (setq index (atoi product)) ; 
        (command "_.-layer" "_S" "00-Equipment List" "") ; 
        (command "_.text" pt *default-text-height* 0 product) ; 
        (command "_.-layer" "_S" "0" "") ; 
      )
    )
    
    ; List update function
    (defun update_list (filter_text / filtered_list)
      (setq filtered_list
        (if (= filter_text "")
          product_list
          (vl-remove-if-not
            '(lambda (x) (vl-string-search (strcase filter_text) (strcase x)))
            product_list
          )
        )
      )
      (start_list "product_list")
      (mapcar 'add_list filtered_list)
      (end_list)
      (set_tile "product_list" "")
    )

    In my dcl code as follows

    Code:
    product_select : dialog {
      label = "Product Select";
      : edit_box {
        key = "search_box";
        label = "search";
        width = 40;
      }
      : button {
        key = "search_button";
        label = "search";
        is_default = true;
      }
      : list_box {
        key = "product_list";
        multiple_select = false;
        fixed_width = true;
        width = 40;
      }
      ok_cancel;
    }

  2. #2
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    561
    Login to Give a bone
    1

    Default Re: Selecting text from a pop-up window and pasting it on the screen

    "but it is based on the line number I choose, not the product name I choose"

    When you get the line number just (nth (- num 1) product_list) should return the correct string.

    Thinking more try

    (setq product (nth (- (atoi $value) 1) product_list))

Similar Threads

  1. 2013: Revit MEP 2013 is de-selecting components and selecting browser items!
    By enerGwizz in forum Revit MEP - General
    Replies: 1
    Last Post: 2013-01-12, 09:48 PM
  2. Screen resolution affecting pasting
    By baili37 in forum AutoLISP
    Replies: 2
    Last Post: 2008-10-20, 02:24 PM
  3. Copying and pasting text masks
    By jpaulsen in forum AutoCAD General
    Replies: 1
    Last Post: 2004-07-26, 01:10 AM
  4. Replies: 6
    Last Post: 2004-07-15, 03:20 PM
  5. Note Block Number order and Text pasting
    By Henry D in forum Revit Architecture - General
    Replies: 12
    Last Post: 2003-11-29, 05:41 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
  •