Results 1 to 8 of 8

Thread: LISP: change attribute value through edit-box (custom dialogbox)

  1. #1
    Member
    Join Date
    2015-05
    Posts
    14
    Login to Give a bone
    0

    Default LISP: change attribute value through edit-box (custom dialogbox)

    Hi,

    Little question.
    I'm trying to fill in an attribute with the value that is given by the user through a editbox.

    I created a function to:
    1 clear values of certain attributes of block X
    2 set the current date in the attribute DATE of the block
    3 set the value of drawn, verified & approved with the values given by the user in the editboxes of the dialog.

    It works when I execute the function on 1 open drawing.
    When I call the function in a routine for processing on an entire folder of drawings, points 1 and 2 are executed, but 3 doesn't seem to work.

    When are the values of the editboxes being placed in the given variables? Is this at the clicking of "OK" or after the closing of the box?
    I can't seem to find why the code works directly on a drawing, but not on an entire folder.
    Last edited by Metalgooze; 2015-08-06 at 07:47 AM.

  2. #2
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: LISP: change attribute value through edit-box (custom dialogbox)

    I haven't looked at your code yet, but how are you batch processing; ObjectDBX, or Script?
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  3. #3
    Member
    Join Date
    2015-05
    Posts
    14
    Login to Give a bone
    0

    Default Re: LISP: change attribute value through edit-box (custom dialogbox)

    Quote Originally Posted by BlackBox View Post
    I haven't looked at your code yet, but how are you batch processing; ObjectDBX, or Script?
    Batch processing through script.

  4. #4
    Member
    Join Date
    2015-05
    Posts
    14
    Login to Give a bone
    0

    Question Re: LISP: change attribute value through edit-box (custom dialogbox)

    Hi (again),

    Little update.
    I've split my code in 2 different LISP's. (1 with the dialogbox and language selection and 1 with the command to clear attributes of a block, the custom command is now automatically loaded when a drawing opens)

    Everything works every time except for 1 thing:

    Because there are now 2 scripts, I need to store the users input in a "global" variable.

    In my "MAIN"-lisp I wrote the following things.
    When the user presses the OK button this is what happens:
    Code:
      (action_tile
        "accept"				;if O.K. pressed
        (strcat				;string 'em together
          "(progn 
          (setq selected_language (atof (get_tile \"selections\")));get list selection
          (setq DELV (get_tile \"drawn\")) ;store value of drawn in variable DELV
          (setq VERIF (get_tile \"verified\")) ;store value of verified in variable VERIF
          (setq APPR (get_tile \"aproved\")) ;store value of aproved in variable APPR
          (val1)(setq userclick T))"	;check fields, set flag
        )
    2 questions:

    - Is it possible that after the execution of the function, the values of the variables are set to NIL?
    - Can you use a variable from one LISP in another LISP? If yes, what's the best way to do this?
    Last edited by BlackBox; 2015-08-06 at 01:03 PM. Reason: Please use [CODE] Tags

  5. #5
    Member
    Join Date
    2015-05
    Posts
    14
    Login to Give a bone
    0

    Cool Re: LISP: change attribute value through edit-box (custom dialogbox)

    Problem solved.

    The reason the names wouldn't be filled in in the attribute is the following:
    A variable (and it's value) "belongs" to the drawing where the command is started (for example Val1 in drawing 1 has the value 1)
    When you process the lisp in batch (through script), every dwg has its own variable Val1 BUT the value is nil.
    so you get this:
    Code:
    drawing 1 - val1 =1
    drawing 2-  val1=nil
    drawing 3-  val1=nil
    drawing 4-  val1=nil
    ...
    You have to "push" the value of val1 from the first drawing to all other dwgs.
    I used vl-propagate to do this (added this to the actions of my "OK"button).
    (vl-propagate sets the value of a variable to any other open or to be opened drawings within an autocad session)
    for example:
    Code:
    (vl-propagate 'val1)
    Maybe it is not the best solution, but it works
    Last edited by BlackBox; 2015-08-06 at 01:03 PM. Reason: Added [CODE] Tags

  6. #6
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: LISP: change attribute value through edit-box (custom dialogbox)

    Apologies for my delayed response; work is increasingly demanding of my time.

    Firstly, I'm glad you were able to find a solution for yourself - they're the best lessons one can learn.

    To perhaps help clarify 'why' that is a working solution....

    LISP is a Document (read Drawing) level API, which is why it must be loaded into each-and-every-single drawing (unlike .NET, for example, which is an Application level API). So variables set in one Document are not 'visible' to even other Documents already open in the Editor, without the use of one of a few available mechanisms, such as propagation.

    Cheers
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  7. #7
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: LISP: change attribute value through edit-box (custom dialogbox)

    Quote Originally Posted by Metalgooze View Post
    Code:
      (action_tile
        "accept"				;if O.K. pressed
        (strcat				;string 'em together
          "(progn 
          (setq selected_language (atof (get_tile \"selections\")));get list selection
          (setq DELV (get_tile \"drawn\")) ;store value of drawn in variable DELV
          (setq VERIF (get_tile \"verified\")) ;store value of verified in variable VERIF
          (setq APPR (get_tile \"aproved\")) ;store value of aproved in variable APPR
          (val1)(setq userclick T))"	;check fields, set flag
        )
    There is no need for the strcat & progn functions with action_tile.

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

    Default Re: LISP: change attribute value through edit-box (custom dialogbox)

    If you want to do over multiple dwg's you may have to consider using a script this can open multiple dwgs and then run a lisp, but to maintain values between dwgs you could write a txt file and just reread & write using lisp. A lisp can write a script etc and then call it as the very last step, control then goes to the lisp but the script sits in background if not finished.

    This post may be of interest also an auto multi line DCl creator http://www.cadtutor.net/forum/showth...re-if-required

Similar Threads

  1. Lisp: Autocad crashes ( on dialogbox?)
    By Metalgooze in forum AutoLISP
    Replies: 5
    Last Post: 2015-07-31, 11:57 AM
  2. Replies: 3
    Last Post: 2014-01-02, 07:54 PM
  3. Attribute color change through LISP
    By bradley.palmer407325 in forum AutoCAD Customization
    Replies: 1
    Last Post: 2012-09-27, 11:32 AM
  4. Replies: 0
    Last Post: 2008-02-08, 04:31 AM
  5. Replies: 8
    Last Post: 2006-05-29, 05:34 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
  •