Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Image_button tile support

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
tcoley95E9Z
373 Views, 3 Replies

Image_button tile support

I want my .dcl program to store a value that is the x,y coordinate point of the users selection within the image button.

This image_button support within autodesk:

https://help.autodesk.com/view/OARX/2022/ENU/?guid=GUID-C1E7FFC9-065F-4975-B356-CF31474B6746

Shows this image:

tcoley95E9Z_0-1716220056556.png

followed by:

"When the user selects an image button, the program obtains the coordinates of the point that was selected"

 

I cannot find any support on storing this data! I want to make a simple program that has 4 points (0,90,180,270) which will run a dedicated command per each quadrant selected. Ideas?

 

Labels (5)
3 REPLIES 3
Message 2 of 4
paullimapa
in reply to: tcoley95E9Z

The clue is to review the original DDVPOINT.lsp & DDVPOINT.dcl files (attached for your reference) that accompanied AutoCAD back in Release 12 which I mentioned in my recent article.

I've attached both of these for your reference.

Like the current VPOINT command the original DDVPOINT lisp command opened this window:

paullimapa_0-1716235914168.png

The dcl shows the image button with the following properties:

    : row {
      fixed_width = true;
      fixed_height = true;
      : image_button {
        alignment = top;
        fixed_width = true;
        fixed_height = true;
        key    = "ddvp_image";
        width  = 39;
        height = 14;
        color  = 0;
      }
    }

Since the image_button has the following key = "ddvp_image", the lisp code reveals the following action:

(action_tile "ddvp_image" "(ai_ddvp_image $x $y)")

The action calls for a function called ai_ddvp_image with the x & y selected coordinates from the image_button as arguments and that function looks like this:

(defun ai_ddvp_image (x y / ang1 ang2 list_xy list_axby list_bxby)
  (setq list_xy (list x y)
        list_axby (list ai_ddvp_ax ai_ddvp_by)
        list_bxby (list ai_ddvp_bx ai_ddvp_by)
  )
  (if (> x (- ai_ddvp_ax 1))
    (progn
      (setq ang1 (ai_rtd (- (* 2.0 pi) (angle list_xy list_axby))))
      (if (< 90.0 ang1)
        (setq ang1 (- ang1 180.0))
      )
      (if (< (distance list_xy list_axby) 40)
        (ai_ddvp_set_a ang1)
        (if (< (distance list_xy list_axby) 84)
          (cond ((= ang1 0.0)
                 (ai_ddvp_set_a 0.0)
                )
                ((< ang1 -72.0)
                 (ai_ddvp_set_a -90.0)
                )
                ((< ang1 -53.0)
                 (ai_ddvp_set_a -60.0)
                )
                ((< ang1 -38.0)
                 (ai_ddvp_set_a -45.0)
                )
                ((< ang1 -20.0)
                 (ai_ddvp_set_a -30.0)
                )
                ((< ang1 -6.0)
                 (ai_ddvp_set_a -10.0)
                )
                ((< ang1 6.0)
                 (ai_ddvp_set_a 0.0)
                )
                ((< ang1 20.0)
                 (ai_ddvp_set_a 10.0)
                )
                ((< ang1 38.0)
                 (ai_ddvp_set_a 30.0)
                )
                ((< ang1 53.0)
                 (ai_ddvp_set_a 45.0)
                )
                ((< ang1 72.0)
                 (ai_ddvp_set_a 60.0)
                )
                (T
                 (ai_ddvp_set_a 90.0)
                )
          )
        )
      )
    )
    (progn
      (setq ang2 (ai_rtd (+ pi (- (* 2.0 pi) (angle list_xy list_bxby)))))
      (if (< 360.0 ang2)
        (setq ang2 (- ang2 360.0))
      )
      (if (< (distance list_xy list_bxby) 40)
        (ai_ddvp_set_b ang2)
        (cond ((= ang2 0.0)
               (ai_ddvp_set_b 0.0)
              )
              ((< ang2 22.5)
               (ai_ddvp_set_b 0.0)
              )
              ((< ang2 67.5)
               (ai_ddvp_set_b 45.0)
              )
              ((< ang2 112.5)
               (ai_ddvp_set_b 90.0)
              )
              ((< ang2 157.5)
               (ai_ddvp_set_b 135.0)
              )
              ((< ang2 202.5)
               (ai_ddvp_set_b 180.0)
              )
              ((< ang2 247.5)
               (ai_ddvp_set_b 225.0)
              )
              ((< ang2 292.5)
               (ai_ddvp_set_b 270.0)
              )
              ((< ang2 337.5)
               (ai_ddvp_set_b 315.0)
              )
              ((< ang2 360.0)
               (ai_ddvp_set_b 0.0)
              )
              (T
               (ai_ddvp_set_b 270.0)
              )
        )
      )
    )
  )
)

Now all that's left is for you to figure out how to filter the x,y selection to get the desired: (0,90,180,270)

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 3 of 4
CodeDing
in reply to: tcoley95E9Z

@tcoley95E9Z ,

 

Here's my quick version to help you out.

Resources:

>>image_button Tile<< 

>>dimx_tile<< 

>>dimy_tile<< 

>>fill_image Tile<< 

>>action_tile<< (this mentions the $x and $y values you were looking for) 

 

DCL Dialog:

image.png

 

When I select the Upper-Right quadrant:

image.png

 

The DCL code:

dlgTest : dialog
{
  label = "Identify Quadrant";
  : image_button
  {
    key = "myimage";
    height = 10;
    width = 75;
  }
  ok_cancel;
}

 

The Lisp Code:

(defun c:TEST ( / DetermineQuadrant fPath dcl-id imgKey imgWidth imgHeight endValue imgButtonPress xCoord yCoord)
  ;; Helper Function
  (defun DetermineQuadrant (w h x y / )
    (setq xPos (> x (fix (* 0.5 w))))
    (setq yPos (> y (fix (* 0.5 h))))
    (cond
      ((and xPos (not yPos)) 1)
      ((and (not xPos) (not yPos)) 2)
      ((and (not xPos) yPos) 3)
      ((and xPos yPos) 4)
    );cond
  )
  ;; Load Dialog
  (setq fPath "c:\\users\\me\\test.dcl") ;<<===== Be sure to update path
  (setq dcl-id (load_dialog fPath))
  (if (not (new_dialog "dlgTest" dcl-id))
    (exit)
  );if
  ;; Establish dialog size and create quadrants
  (setq imgKey "myimage")
  (setq imgWidth (dimx_tile imgKey) imgHeight (dimy_tile imgKey))
  (start_image imgKey)
  (fill_image (fix (* 0.5 imgWidth)) 0 5 imgHeight 1)
  (fill_image 0 (fix (* 0.5 imgHeight)) imgWidth 5 1)
  (end_image)
  ;; Establish actions on tiles
  (action_tile
    imgKey
    "(done_dialog) (setq imgButtonPress t xCoord $x yCoord $y)"
  )
  (action_tile
    "cancel"
    "(done_dialog) (setq endValue \"User clicked Cancel.\")"
  )
  (action_tile
    "accept"
    "(done_dialog) (setq endValue \"User clicked Accept.\")"
  )
  ;; Run dialog & handle end states
  (start_dialog)
  (unload_dialog dcl-id)
  (cond
    (imgButtonPress
      (alert
        (princ
          (strcat
            "\nImage Button Pressed."
            "\nX: " (itoa xCoord)
            "\nY: " (itoa yCoord)
            "\nQuadrant: " (itoa (DetermineQuadrant imgWidth imgHeight xCoord yCoord))
          );strcat
        );princ
      );alert
    )
    (endValue
      (alert (print (strcat "\nYour 'endValue' was: " endValue)))
    )
  );cond
  (princ)
)

 

Best,

~DD


Need AutoLisp help? Try my custom GPT 'AutoLISP Ace':
https://chat.openai.com/g/g-Zt0xFNpOH-autolisp-ace
Message 4 of 4
Sea-Haven
in reply to: tcoley95E9Z

Another method is use a 2x2 image dcl so can make 4 slides like Vpoint image cut into 4, nice thing is when you pick a corner it just returns say Quad1. 

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Autodesk Design & Make Report