See the top rated post in this thread. Click here

Page 1 of 6 12345 ... LastLast
Results 1 to 10 of 60

Thread: LSP & DCL Change Font/Colors & Add Image?

  1. #1
    I could stop if I wanted to
    Join Date
    2006-02
    Posts
    424
    Login to Give a bone
    0

    Default LSP & DCL Change Font/Colors & Add Image?

    Greetings AUGI people!

    I have decided to go with the code listed below...in my previous thread: http://forums.augi.com/showthread.php?t=86957
    I was discussing creating a read-only button and I have since decided not to develop that for now.

    My questions today are this:
    1. How do I add a .bmp image (that is stored on a network drive) to show up in the dialog box?

    2. How do I change the font of the text that appears in the dialog box? I would like to make the font large, bolder, and perhaps a different font style altogether.

    3. How do I change the color of the font? How do I change the color of the "buttons", how do I change the color of the background of the dialog box? Basically what are all the ways to manipulate colors in the dialog box.

    4. How do I get my dialog box to print out the "acadv" variable? I am wanting it to state something along the lines of: Warning you have just opened a "acadv" dwg.... Is this possible?

    Here is my current LSP file
    Code:
    ;;;;
    ;;;;Beginning of the AutoLISP routine
    ;;;
    
      (setq dwgfile (strcat (getvar "dwgprefix")(getvar "dwgname")))
      (setq rfile (open dwgfile "r"))
      (setq dwgver (substr (read-line rfile) 1 6))
      (close rfile)
    
      (cond
        
        ((= dwgver "AC1021")
         (close)
         )
        ((= dwgver "AC1014")
         (setq acadv "AutoCAD R14")
         )
        ((= dwgver "AC1012")
         (setq acadv "AutoCAD R13")
         )
        ((= dwgver "AC1009")
         (setq acadv "AutoCAD R11 or R12")
         )
        ((= dwgver "AC1006")
         (setq acadv "AutoCAD R10")
         )
        ((= dwgver "AC1004")
         (setq acadv "AutoCAD R9")
         )
        ((= dwgver "AC1002")
         (setq acadv "AutoCAD R2.6")
         )
        ((= dwgver "AC1.50")
         (setq acadv "AutoCAD R2.05")
        )
        ((= dwgver "AC1015")
         (setq acadv "AutoCAD 2000")
        )
        ((= dwgver "AC1016")
         (setq acadv "AutoCAD 2000i")
        )
        ((= dwgver "AC1017")
         (setq acadv "AutoCAD 2002")
        )
        ((= dwgver "AC1018")
         (setq acadv "AutoCAD 2004")
        )
        ((= dwgver "AC1019")
         (setq acadv "AutoCAD 2005")
        )
        ((= dwgver "AC1020")
         (setq acadv "AutoCAD 2006")
        )
    ;;;;    ((= dwgver "AC1022")
    ;;;;     (setq acadv "AutoCAD 2008")
    ;;;;    )
    ;;;;    ((= dwgver "AC1023")
    ;;;;     (setq acadv "AutoCAD 2009")
    ;;;;    )
       )
    
    (setq dclid (load_dialog "warnr14.dcl"))
    (new_dialog "warnr14" dclid)
    (defun edit_action1 (val)
    (setq NT val)
    )
    
    (action_tile "accept" "(unload_dialog)")
    (action_tile "cancel" "(done_dialog)")
    
    (start_dialog)
    
    (done_dialog)
    (command "_.close")
    (command "y")
    
    
    (unload_dialog dclid)
     
      )
    
    ;;;;
    ;;;;End of the AutoLISP routine
    Here is my DCL code:
    Code:
    warnr14 : dialog {
    
    	label = "WARNING!!! WARNING!!!";
    
    	: image {
    	key = "im";
    	height = 1.0;
    	width = 1.0;
    	color = 1;
    	}
    	
    	: paragraph {
    	: text_part {
    	label = "YOU JUST OPENED AN R14 DWG IN 2007.";
    	}
    	: text_part {
    	label = "Verify this file is Read-only before clicking 'Open' (Check the header).";
    	}
    	: text_part {
    	label = "If you ignore this warning and end up saving this as a 2007 dwg, YOU WILL REPAIR THIS FILE ON YOUR OWN TIME!!";
    	}
    	}
    
    	: image {
    	key = "im2";
    	height = 1.0;
    	width = 1.0;
    	color = 1;
    	}
    
    	: row {
    
    	: button {
    	label = "CANCEL";
    	key = "cancel";
    	mnemonic = "C";
    	alignment = centered;
    	width = 0.5;
    	height = 3;
    	is_default = true;
    	}
    	
    	: button {
    	fixed_width = true;
    	fixed_height = true;
    	label = "Open";
    	key = "accept";
    	mnemonic = "O";
    	}
    
    }
    }
    Last edited by A Meador; 2008-09-24 at 02:48 PM.

  2. #2
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,803
    Login to Give a bone
    0

    Default Re: LSP & DCL Change Font/Colors & Add Image?

    If you are using LISP and DCL only, then...

    1. Can't be done. You can use a slide image however.
    2. All you can really do here is make it monospaced and/or bold (look at the IS_BOLD and FIXED_WIDTH_FONT attributes)
    3. Can't be done.
    4. Set the tile to the value of the variable... (set_tile "mytile" (getvar "dwgname"))

    You may or may not be able to do #1 and #3 using OpenDCL
    R.K. McSwain | CAD Panacea |

  3. #3
    I could stop if I wanted to
    Join Date
    2006-02
    Posts
    424
    Login to Give a bone
    0

    Default Re: LSP & DCL Change Font/Colors & Add Image?

    Thank you for your reply.

    Couple of return questions...
    I am not very knowledgeable about LSP and DCL codes.
    I have hobbled this together...
    Therefore, I don't know where to place the line of code that you mentioned in #4's answer.
    (set_tile "mytile" (getvar "dwgname"))
    I assume by the syntax that it should go in the LSP, but where? and what is "mytile" ?
    Also...how does this get passed on to the DCL to show up in the middle of the text that the DCL is showing?

    On your answer to #1, how can I create a slide to use from the .bmp that I have?
    I have not done slides before.
    How do I then get that to show up on the DCL's pop-up?

    Thank you for your help!

  4. #4
    I could stop if I wanted to
    Join Date
    2006-07
    Posts
    233
    Login to Give a bone
    0

    Default Re: LSP & DCL Change Font/Colors & Add Image?

    to make a slide image you will need to insert the .bmp image into autocad and use the autocad command mslide. This will prompt you to save the file as a slide file with the .sld extension. This you will be able to use in the dcl.

    Use this below code to update the image after you have the mysldname variable set to you image file path.
    Code:
    (defun upDateImage(sldName key)          
    
      ;;;--- Get the width of the slide
      (setq width (dimx_tile key))
    
      ;;;--- Get the height of the slide 
      (setq height (dimy_tile key))
    
      ;;;--- Start the slide definition
      (start_image key)
    
      ;;;--- Wipe out the background
      (fill_image 0 0 width height 0)
    
      ;;;--- Put the slide in the image area
      (slide_image 0 0 width height sldName)
    
      ;;;--- Finish the slide definition
      (end_image)
    Use The below code in an action_tile call to set the image and update the dcl
    Code:
      (setq mySlideName "My Image Path.sld")
      ;;;--- Second we need the key to the image control 
    (setq myKey "sld")
      ;;;--- Use the below to call the upDateImage function to update images when there are more than one you amy need to call to
     (upDateImage mySlideName myKey)

  5. #5
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,803
    Login to Give a bone
    0

    Default Re: LSP & DCL Change Font/Colors & Add Image?

    Quote Originally Posted by ameador View Post
    Therefore, I don't know where to place the line of code that you mentioned in #4's answer.
    (set_tile "mytile" (getvar "dwgname"))
    Using the sample code provided by Autodesk in the developers guide...

    Code:
    
    
    ///DCL FILE
    hello : dialog {
        label = "Sample Dialog Box";
        : text { key = "mytile"; }//changed this line
        ok_only;
    }
    
    ;;; LISP CODE
    (defun C:HELLO( / dcl_id )
      (setq dcl_id (load_dialog "hello.dcl")) ; Load the DCL file.
      (if (not (new_dialog "hello" dcl_id))   ; Initialize the dialog.
        (exit)                                ; Exit if this doesn't 
                                              ; work.
      )
      (set_tile "mytile" (getvar "dwgname"));Set 'mytile' to current drawing name (added this line)
    
      (start_dialog)                          ; Display the dialog 
                                              ; box.
      (unload_dialog dcl_id)                  ; Unload the DCL file.
      (princ)
    )
    
    Hope that helps...
    R.K. McSwain | CAD Panacea |

  6. #6
    I could stop if I wanted to
    Join Date
    2006-02
    Posts
    424
    Login to Give a bone
    0

    Default Re: LSP & DCL Change Font/Colors & Add Image?

    rkmcswain:
    Ok, with the info you supplied I can get the dwg name to show up on the dialog box, yeah!

    But, I'm not wanting the dwg name to show up, I'm wanting it to display the version number that the lsp has assigned to the "acadv" variable. When I go through and substitute the acadv in instead of the dwgname it doesn't work. (the dialog box flashes up on the screen and then disappears quickly w/o clicking on the cancel or ok button)

    I've tried modifying it to:
    (set_tile "mytile" (acadv))

    and I've tried: (with and without the quotes around the dwgver variable)
    (set_tile "mytile" ("dwgver"))

    But this doesn't seem to help.
    Any other suggestions?
    Thank you!!

  7. #7
    I could stop if I wanted to
    Join Date
    2006-02
    Posts
    424
    Login to Give a bone
    0

    Default Re: LSP & DCL Change Font/Colors & Add Image?

    Lions60:
    I was able to create the .sld image (wahoo!) but when I place it in my code it didn't work.
    By "it didn't work" I mean the dialog box shows up but does not have the slide image on it. I stored the slide image that I created on our network, should it matter where it is stored?

    It is entirely possible that I am placing the code in the wrong location.

    (((FYI, I am testing the image stuff separately from the acadv/dwgver stuff so I know that what I am changing to test one vs the other is not interfering with the results))))

    How should I get this to show up in the .dcl? Or do I need to?

    Here's what I have on the lsp:
    Code:
    ;;;;
    ;;;;Beginning of the AutoLISP routine
    ;;;
    
      
      (setq dwgfile (strcat (getvar "dwgprefix")(getvar "dwgname")))
      (setq rfile (open dwgfile "r"))
      (setq dwgver (substr (read-line rfile) 1 6))
      (close rfile)
    
      (cond
        
        ((= dwgver "AC1021")
         (close)
         )
        ((= dwgver "AC1014")
         (setq acadv "AutoCAD R14")
         )
        ((= dwgver "AC1012")
         (setq acadv "AutoCAD R13")
         )
        ((= dwgver "AC1009")
         (setq acadv "AutoCAD R11 or R12")
         )
        ((= dwgver "AC1006")
         (setq acadv "AutoCAD R10")
         )
        ((= dwgver "AC1004")
         (setq acadv "AutoCAD R9")
         )
        ((= dwgver "AC1002")
         (setq acadv "AutoCAD R2.6")
         )
        ((= dwgver "AC1.50")
         (setq acadv "AutoCAD R2.05")
        )
        ((= dwgver "AC1015")
         (setq acadv "AutoCAD 2000")
        )
        ((= dwgver "AC1016")
         (setq acadv "AutoCAD 2000i")
        )
        ((= dwgver "AC1017")
         (setq acadv "AutoCAD 2002")
        )
        ((= dwgver "AC1018")
         (setq acadv "AutoCAD 2004")
        )
        ((= dwgver "AC1019")
         (setq acadv "AutoCAD 2005")
        )
        ((= dwgver "AC1020")
         (setq acadv "AutoCAD 2006")
        )
    ;;;;    ((= dwgver "AC1022")
    ;;;;     (setq acadv "AutoCAD 2008")
    ;;;;    )
    ;;;;    ((= dwgver "AC1023")
    ;;;;     (setq acadv "AutoCAD 2009")
    ;;;;    )
    
      )
    
    (setq dclid (load_dialog "warnr14.dcl"))
    (new_dialog "warnr14" dclid)
    (defun edit_action1 (val)
    (setq NT val)
    )
    
    (setq x (dimx_tile "view")
    	y (dimy_tile "view"))
    (start_image "view")
    ( slide_image 0 0 x y "WarnImage")
    
    (action_tile "accept" "(unload_dialog)")
    (action_tile "cancel" "(done_dialog)")
    
    (start_dialog)
    
    (done_dialog)
    (command "_.close")
    (command "y")
    
    (unload_dialog dclid) 
    (end_image)
      )
    
    ;;;;
    ;;;;End of the AutoLISP routine

  8. #8
    I could stop if I wanted to
    Join Date
    2006-07
    Posts
    233
    Login to Give a bone
    0

    Default Re: LSP & DCL Change Font/Colors & Add Image?

    I forgot to also tell you that there is code you need to add to your dcl. To get the image to display

    Code:
          : image { 
                    key = "sld"; 
                    height = 5; 
                    width = 15;  
                    color = 0;
                    is_enabled = false; 
                    is_tab_stop = false;
                  }
    Here is how I would use it
    Code:
    (defun upDateImage(sldName key)          
    
      ;;;--- Get the width of the slide
      (setq width (dimx_tile key))
    
      ;;;--- Get the height of the slide 
      (setq height (dimy_tile key))
    
      ;;;--- Start the slide definition
      (start_image key)
    
      ;;;--- Wipe out the background
      (fill_image 0 0 width height 0)
    
      ;;;--- Put the slide in the image area
      (slide_image 0 0 width height sldName)
    
      ;;;--- Finish the slide definition
      (end_image)
    );; end of defun
    
    ;;;;
    ;;;;Beginning of the AutoLISP routine
    ;;;
    
      
      (setq dwgfile (strcat (getvar "dwgprefix")(getvar "dwgname")))
      (setq rfile (open dwgfile "r"))
      (setq dwgver (substr (read-line rfile) 1 6))
      (close rfile)
    
      (cond
        
        ((= dwgver "AC1021")
         (close)
         )
        ((= dwgver "AC1014")
         (setq acadv "AutoCAD R14")
         )
        ((= dwgver "AC1012")
         (setq acadv "AutoCAD R13")
         )
        ((= dwgver "AC1009")
         (setq acadv "AutoCAD R11 or R12")
         )
        ((= dwgver "AC1006")
         (setq acadv "AutoCAD R10")
         )
        ((= dwgver "AC1004")
         (setq acadv "AutoCAD R9")
         )
        ((= dwgver "AC1002")
         (setq acadv "AutoCAD R2.6")
         )
        ((= dwgver "AC1.50")
         (setq acadv "AutoCAD R2.05")
        )
        ((= dwgver "AC1015")
         (setq acadv "AutoCAD 2000")
        )
        ((= dwgver "AC1016")
         (setq acadv "AutoCAD 2000i")
        )
        ((= dwgver "AC1017")
         (setq acadv "AutoCAD 2002")
        )
        ((= dwgver "AC1018")
         (setq acadv "AutoCAD 2004")
        )
        ((= dwgver "AC1019")
         (setq acadv "AutoCAD 2005")
        )
        ((= dwgver "AC1020")
         (setq acadv "AutoCAD 2006")
        )
    ;;;;    ((= dwgver "AC1022")
    ;;;;     (setq acadv "AutoCAD 2008")
    ;;;;    )
    ;;;;    ((= dwgver "AC1023")
    ;;;;     (setq acadv "AutoCAD 2009")
    ;;;;    )
    
      )
    
    (setq dclid (load_dialog "warnr14.dcl"))
    (new_dialog "warnr14" dclid)
    (defun edit_action1 (val)
    (setq NT val)
    )
    
    (setq mykey "sld")
    (setq myslidename "WarnImage.sld")
    (updateimage myslidename mykey)
    
    (action_tile "accept" "(unload_dialog)")
    (action_tile "cancel" "(done_dialog)")
    
    (start_dialog)
    
    (done_dialog)
    (command "_.close")
    (command "y")
    
    (unload_dialog dclid) 
    (end_image)
      )
    
    ;;;;
    ;;;;End of the AutoLISP routine

  9. #9
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,803
    Login to Give a bone
    0

    Default Re: LSP & DCL Change Font/Colors & Add Image?

    Quote Originally Posted by ameador View Post
    Ok, with the info you supplied I can get the dwg name to show up on the dialog box, yeah!

    But, I'm not wanting the dwg name to show up
    That was only an example...

    Quote Originally Posted by ameador
    I'm wanting it to display the version number that the lsp has assigned to the "acadv" variable.

    I've tried modifying it to:
    (set_tile "mytile" (acadv))
    Try this:
    Code:
    
    (set_tile "mytile" acadv)
    
    R.K. McSwain | CAD Panacea |

  10. #10
    I could stop if I wanted to
    Join Date
    2006-02
    Posts
    424
    Login to Give a bone
    0

    Default Re: LSP & DCL Change Font/Colors & Add Image?

    Lions60:
    Ok....this is getting there.....

    Now I have a big white section at the top of my dialog box.
    So my image is not showing up, but there is a "spot" for it, if you will.

    Where should I be storing my .sld file in order for it to be accessing it?

    I am trying to get this to work for everyone on the network, will I need to copy the sld file onto their hard-drives as well, or can it be accessed off of a network location?

    So close on the image thing....

Page 1 of 6 12345 ... LastLast

Similar Threads

  1. 2014: Colors on my image keep inverting after I save
    By tasmith7 in forum Raster Design - General
    Replies: 0
    Last Post: 2014-08-18, 04:21 PM
  2. LISP to change layer colors to random colors
    By mtubbs in forum AutoLISP
    Replies: 10
    Last Post: 2007-04-27, 05:39 AM
  3. Font will change to another font when opening a drawing
    By mellyskelly in forum AutoCAD General
    Replies: 2
    Last Post: 2006-10-21, 05:01 AM
  4. Colors change
    By nikoloz in forum AutoCAD Mechanical - General
    Replies: 2
    Last Post: 2005-09-29, 08:57 AM
  5. Replies: 5
    Last Post: 2005-01-04, 07:19 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
  •