Jump to content

Recommended Posts

  • 6 months later...
  • Replies 305
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    152

  • alanjt

    10

  • The Buzzard

    10

  • mdbdesign

    7

Posted
On 4/12/2009 at 11:37 PM, Lee Mac said:

Hi Guys,

 

Wasn't that busy, so I thought I'd put together a little Incremental Numbering Suite for you all to sample.

 

I've come to realise that this kind of LISP seems to be quite a popular one in many trades, and this was my main inspiration for its creation.

 

As with all my programs - your comments and/or criticism is welcome, as this only helps to improve the program itself.

 

Thanks & Enjoy!

 

Cheers

 

Lee

 

 

Incremental Numbering Suite

 

Main Dialog Preview:

 

http://lee-mac.com/lisp/gifs/NumIncV3-3.png

About Dialog Preview:

 

http://lee-mac.com/lisp/gifs/NumIncV3-3A.png

 

Incrementing two sections of Text with a Background Mask and Rectangular Border:

 

http://lee-mac.com/lisp/gifs/NumInc0.gif

Incrementing with Leading Zeros:

 

http://lee-mac.com/lisp/gifs/NumInc1.gif

 

Text with a Slot Border:

 

http://lee-mac.com/lisp/gifs/NumInc2.gif

Placing text in a Table Cell:

 

http://lee-mac.com/lisp/gifs/NumInc3.gif

 

Incrementing Text with Leading Zeros and Hexagonal Border:

 

http://lee-mac.com/lisp/gifs/NumInc4.gif

 

Incrementing alpha text, demonstrating rotation of Triangular Border:

 

http://lee-mac.com/lisp/gifs/NumInc5.gif

 

Curve-Aligned Mode:

 

http://lee-mac.com/lisp/gifs/NumIncC.gif

Array Example 1

 

Demonstrating the difference between Spacing Vector and Endpoint specification, with Object Rotation set to 'Aligned'.

 

http://lee-mac.com/lisp/gifs/NumIncA1.gif

Array Example 2

 

Demonstrating Perpendicular rotation and a fixed zero rotation.

 

http://lee-mac.com/lisp/gifs/NumIncA2.gif

 

A full description of the program and the latest version can be found here.

NumIncV3-9.zip 31.99 kB · 162 downloads

hi bro
i tried to use that part of your code (img20b) , but failed .
can you help me ? i need that pic on  button.
this is my code.

(vl-load-com)
(defun draw_txt_pik_image ()
  (setq pixels
    '(
      -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15
      -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15
      -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15 -15
      -15 -15 -15 -15 -15 -15 095 096 096 096 096 096 096 096 096 095 -15 -15 -15 -15
      -15 -15 -15 -15 -15 -15 096 254 254 254 254 254 254 254 254 096 -15 -15 -15 -15
      -15 -15 -15 -15 -15 -15 096 063 063 -15 063 063 063 063 063 096 -15 -15 -15 -15
      -15 -15 -15 -15 -15 -15 096 063 -15 250 -15 063 063 063 063 096 -15 -15 -15 -15
      -15 -15 -15 -15 -15 -15 096 -15 250 250 -15 063 063 063 063 096 -15 -15 -15 -15
      -15 -15 -15 -15 -15 -15 254 250 -15 250 -15 063 063 063 063 096 -15 -15 -15 -15
      254 254 254 254 254 254 250 -15 -15 250 -15 063 063 063 063 096 254 254 254 254
      254 254 254 254 254 250 -15 -15 -15 250 -15 063 063 063 063 096 254 254 254 254
      254 254 254 254 250 -15 -15 -15 -15 250 -15 063 063 063 063 096 254 254 254 254
      254 254 254 250 250 250 -15 -15 -15 250 -15 063 063 063 063 096 254 254 254 254
      254 254 254 254 254 250 -15 250 -15 250 -15 063 063 063 063 096 254 254 254 254
      254 254 254 254 254 250 -15 250 250 250 -15 063 063 063 063 096 254 254 254 254
      254 254 254 254 250 -15 250 254 254 250 254 096 096 096 096 095 254 254 254 254
      254 254 254 254 250 -15 250 254 254 254 254 254 254 254 254 254 254 254 254 254
      254 254 254 254 254 250 254 254 254 254 254 254 254 254 254 254 254 254 254 254
      254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254
      -15 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 254 -15
    )
  )
  (setq x nil y nil)
  (repeat 20 (repeat 20 (setq x (cons (length x) x))))
  (setq y (reverse x))

  (start_image "txt-pik")
  (fill_image 0 0 20 20 -15)
  (mapcar 'vector_image x y x y pixels)
  (end_image)
)

(defun pick-text-height-with-mouse ( / pt1 pt2 )
  (setq pt1 (getpoint "\nSelect first point for text height: "))
  (if pt1
    (progn
      (setq pt2 (getpoint pt1 "\nSelect second point: "))
      (if pt2
        (distance pt1 pt2)
        nil
      )
    )
    nil
  )
)


(defun hatch-circle-by-layer (layer-name color / ss i ent doc space hatch loopArray)
  (if (layer-exists-p layer-name)
    (progn
      (setq ss (ssget "X" (list '(0 . "CIRCLE") (cons 8 layer-name))))
      (if ss
	(progn
	  (setq doc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
	  (setq	space (if (= (getvar "CVPORT") 1)
			(vla-get-PaperSpace doc)
			(vla-get-ModelSpace doc)
		      )
	  )
	  (setq i 0)
	  (while (< i (sslength ss))
	    (setq ent (vlax-ename->vla-object (ssname ss i)))
	    (setq hatch	(vla-AddHatch
			  space
			  acHatchPatternTypePreDefined
			  "SOLID"
			  :vlax-true
			)
	    )
	    (setq loopArray (vlax-make-safearray vlax-vbObject '(0 . 0)))
	    (vlax-safearray-put-element loopArray 0 ent)
	    (vla-AppendOuterLoop hatch loopArray)
	    (vla-Evaluate hatch)
	    (vla-put-Layer hatch layer-name)
	    (vla-put-Color hatch color)
	    (setq i (1+ i))
	  )
	)
      )
    )
  )
)
(defun insert-field-values
			   (name	    father_name	    personal_code   address	    company_name    boss_name	    melli_code
			    shomare_parvaneh		    shomare_sabt    address_mojri   tedade_tabaghat tedade_vahed    tabaghe_vahed
			    jahate_vahed    txt_size	    build_val	    plumb_val	    coat_val	    standard_val    sealing_val
			    /		    blk		    ent		    att		    tag
			   )

  (setq blk (entnext))
  (while blk
    (if	(= (cdr (assoc 0 (entget blk))) "INSERT")
      (progn
	(setq ent (entnext blk))
	(while (and ent (/= (cdr (assoc 0 (entget ent))) "SEQEND"))
	  (setq att (entget ent))
	  (if (= (cdr (assoc 0 att)) "ATTRIB")
	    (progn
	      (setq tag (strcase (cdr (assoc 2 att))))
	      (cond
		((= tag "NAME")
		 (entmod (subst (cons 1 name) (assoc 1 att) att))
		)
		((= tag "FATHER_NAME")
		 (entmod (subst (cons 1 father_name) (assoc 1 att) att))
		)
		((= tag "PERSONAL_CODE")
		 (entmod (subst (cons 1 personal_code) (assoc 1 att) att))
		)
		((= tag "ADDRESS")
		 (entmod (subst (cons 1 address) (assoc 1 att) att))
		)
		((= tag "COMPANY_NAME")
		 (entmod (subst (cons 1 company_name) (assoc 1 att) att))
		)
		((= tag "BOSS_NAME")
		 (entmod (subst (cons 1 boss_name) (assoc 1 att) att))
		)
		((= tag "MELLI_CODE")
		 (entmod (subst (cons 1 melli_code) (assoc 1 att) att))
		)
		((= tag "SHOMARE_PARVANEH")
		 (entmod (subst (cons 1 shomare_parvaneh) (assoc 1 att) att))
		)
		((= tag "SHOMARE_SABT")
		 (entmod (subst (cons 1 shomare_sabt) (assoc 1 att) att))
		)
		((= tag "ADDRESS_MOJRI")
		 (entmod (subst (cons 1 address_mojri) (assoc 1 att) att))
		)
		((= tag "TEDADE_TABAGHAT")
		 (entmod (subst (cons 1 tedade_tabaghat) (assoc 1 att) att))
		)
		((= tag "TEDADE_VAHED")
		 (entmod (subst (cons 1 tedade_vahed) (assoc 1 att) att))
		)
		((= tag "TABAGHE_VAHED")
		 (entmod (subst (cons 1 tabaghe_vahed) (assoc 1 att) att))
		)
		((= tag "JAHATE_VAHED")
		 (entmod (subst (cons 1 jahate_vahed) (assoc 1 att) att))
		)

	      )
	    )
	  )
	  (setq ent (entnext ent))
	)
      )
    )
    (setq blk (entnext blk))
  )
)
(defun c:a (/ dcl_id result name father_name personal_code address company_name boss_name
              melli_code shomare_parvaneh shomare_sabt address_mojri tedade_tabaghat
              tedade_vahed tabaghe_vahed jahate_vahed build_val plumb_val coat_val
              standard_val sealing_val *hatch-color* picked-height picked-from-mouse)
;;;  (setq txt_size "2.5") ; always reset
;;;(draw_txt_pik_image)
  (or *hatch-color* (setq *hatch-color* 1))

  (setq dcl_id (load_dialog "project_input.dcl"))
  (if (not (new_dialog "field_dialog" dcl_id))
    (progn (alert "Cannot load dialog file.") (exit))
  )

  (draw_txt_pik_image)

  ;; apply default txt_size only if not picked by mouse

(if txt_size (set_tile "txt_size" txt_size))




  ;; radio button defaults
  (set_tile "building_type" "commercial")
  (set_tile "plumbing_type" "both")
  (set_tile "coating_type" "both2")
  (set_tile "standard" "ISIRI")
  (set_tile "sealing_type" "standard_sealing")

  ;; color preview function
  (defun update_color_preview ()
    (start_image "color_preview")
    (fill_image 0 0 (dimx_tile "color_preview") (dimy_tile "color_preview") *hatch-color*)
    (end_image)
  )
  (update_color_preview)

  ;; color buttons
  (action_tile "color_btn" "(progn (setq *hatch-color* (acad_colordlg *hatch-color*)) (update_color_preview))")
  (action_tile "color_preview" "(progn (setq *hatch-color* (acad_colordlg *hatch-color*)) (update_color_preview))")

  ;; accept inputs
  (action_tile "accept"
    (strcat
      "(progn "
      "(setq name (get_tile \"name\")) "
      "(setq father_name (get_tile \"father_name\")) "
      "(setq personal_code (get_tile \"personal_code\")) "
      "(setq address (get_tile \"address\")) "
      "(setq company_name (get_tile \"company_name\")) "
      "(setq boss_name (get_tile \"boss_name\")) "
      "(setq melli_code (get_tile \"melli_code\")) "
      "(setq shomare_parvaneh (get_tile \"shomare_parvaneh\")) "
      "(setq shomare_sabt (get_tile \"shomare_sabt\")) "
      "(setq address_mojri (get_tile \"address_mojri\")) "
      "(setq tedade_tabaghat (get_tile \"tedade_tabaghat\")) "
      "(setq tedade_vahed (get_tile \"tedade_vahed\")) "
      "(setq tabaghe_vahed (get_tile \"tabaghe_vahed\")) "
      "(setq jahate_vahed (get_tile \"jahate_vahed\")) "
      "(setq txt_size (get_tile \"txt_size\")) "
      "(setq build_val (get_tile \"building_type\")) "
      "(setq plumb_val (get_tile \"plumbing_type\")) "
      "(setq coat_val (get_tile \"coating_type\")) "
      "(setq standard_val (get_tile \"standard\")) "
      "(setq sealing_val (get_tile \"sealing_type\")) "
      "(done_dialog 1))"
    )
  )

  ;; cancel
  (action_tile "cancel" "(done_dialog 0)")

  ;; image button: pick text height
  (action_tile "txt-pik" "(done_dialog 2)")

  ;; show dialog
  (setq result (start_dialog))
  (unload_dialog dcl_id)

  (cond
    ;; accept
    ((= result 1)
     ;; reset flag
     (setq picked-from-mouse nil)

     (insert-field-values
       name father_name personal_code address company_name boss_name melli_code
       shomare_parvaneh shomare_sabt address_mojri tedade_tabaghat
       tedade_vahed tabaghe_vahed jahate_vahed txt_size build_val plumb_val
       coat_val standard_val sealing_val
     )

     (delete-hatch-by-layer
       '("circle_residential" "circle_commercial" "circle_educational" "circle_public"
         "circle_API" "circle_DIN" "circle_gas_tight" "circle_religious"
         "circle_industrial" "circle_concealed" "circle_ISIRI" "circle_PAINTING"
         "circle_STANDARD_SEALING" "circle_wrapping" "circle_exposed" "circle_both"
         "circle_both2")
     )

     (if build_val (hatch-circle-by-layer (strcat "circle_" build_val) *hatch-color*))
     (if plumb_val (hatch-circle-by-layer (strcat "circle_" plumb_val) *hatch-color*))
     (if coat_val (hatch-circle-by-layer (strcat "circle_" coat_val) *hatch-color*))
     (if standard_val (hatch-circle-by-layer (strcat "circle_" standard_val) *hatch-color*))
     (if sealing_val (hatch-circle-by-layer (strcat "circle_" sealing_val) *hatch-color*))

     (princ "\nAll operations completed successfully.")
    )

    ;; pick height
    ((= result 2)
 (setq picked-height (pick-text-height-with-mouse))
 (if picked-height
   (progn
     (setq txt_size (rtos picked-height 2 2))
   )
 )
 (c:a)
)




  )

  (princ)
)





(defun delete-hatch-by-layer (layers / ss i e)
  (foreach lay layers
    (if	(layer-exists-p lay)
      (progn
	(setq ss (ssget "X" (list '(0 . "HATCH") (cons 8 lay))))
	(if ss
	  (progn
	    (setq i 0)
	    (while (< i (sslength ss))
	      (setq e (ssname ss i))
	      (entdel e)
	      (setq i (1+ i))
	    )
	  )
	)
      )
    )
  )
)


(defun layer-exists-p (layerName)
  (tblsearch "LAYER" layerName)
)




(princ)

 

Posted

Does your DCL file define the appropriate image_button tile with key "txt-pik".

Posted
2 hours ago, Lee Mac said:

Does your DCL file define the appropriate image_button tile with key "txt-pik".

field_dialog : dialog {
  label = "Project Information Input";
  spacer;
  : row {
    alignment = centered;
    fixed_width = false;
 children_alignment = top;		
 

    : boxed_radio_column{ fixed_height = true; 
      label = "äæÚ áæáå˜Ôí:";
      key = "plumbing_type";
      : radio_button { label = "Êæí ˜ÇÑ"; key = "concealed"; }
      : radio_button { label = "Ñæí ˜ÇÑ"; key = "exposed"; }
      : radio_button { label = "åÑÏæ"; key = "both"; }
    }

    : boxed_radio_column {fixed_height = true;
      label = "äæÚ æÔÔ:";
      key = "coating_type";
      : radio_button { label = "Ñä ÂãíÒí"; key = "painting"; }
      : radio_button { label = "äæÇÑíí"; key = "wrapping"; }
      : radio_button { label = "åÑÏæ"; key = "both2"; }
    }

    : boxed_radio_column {fixed_height = true;
      label = "ÇÓÊÇäÏÇÑÏ:";
      key = "standard";
      : radio_button { label = "ISIRI 3360"; key = "ISIRI";  }
      : radio_button { label = "API 5L"; key = "API"; }
      : radio_button { label = "DIN 2440"; key = "DIN"; }
    }

    : boxed_radio_column {fixed_height = true; height = 5.8;
      label = "äæÚ ÏÑÒÈäÏí:";
      key = "sealing_type";
      : radio_button { label = "ãÚãæáí"; key = "standard_sealing";  }
      : radio_button { label = "åæÇÈäÏ"; key = "gas_tight"; }
    }
      
    : boxed_column {
     children_alignment = centered;
    height = 5.8;width = 2;
    fixed_width=true;
    fixed_height=true;
      label = "åÇÔæÑ";
    
      : row {  fixed_height=true; fixed_width=true;
        : image_button {
       height=2;   aspect_ratio=1;
          key = "color_preview";
        }
      }
      :text { label = "ÇäÊÎÇÈ";}
       :text { label = "Ñä";}
    }


  }

   : boxed_radio_row{
    fixed_width = false;
    children_alignment = centered;
    label = "äæÚ ÓÇÎÊãÇä:";
      key = "building_type";

 : radio_button { label = "ãÓ˜æäí"; key = "residential";}
      : radio_button { label = "ÊÌÇÑí"; key = "commercial"; }
      : radio_button { label = "ÂãæÒÔí"; key = "educational"; }
      : radio_button { label = "Úãæãí"; key = "public";}
      : radio_button { label = "ãÐåÈí"; key = "religious";}
      : radio_button { label = "ÕäÚÊí"; key = "industrial";}
      }
  spacer ;
       
      :row {

   alignment = centered;
    fixed_width = false;
    
    : column {
      : edit_box {
        key = "tedade_tabaghat";
        edit_width = 10;
         alignment = centered;
    fixed_width = true;
      }
      : text { label = "ÊÚÏÇÏ ØÈÞÇÊ"; alignment = centered; }
    }
    
    : column {
      : edit_box {
        key = "tedade_vahed";
        edit_width = 10;
          alignment = centered;
    fixed_width = true;
      }
      : text { label = "ÊÚÏÇÏ æÇÍÏ"; alignment = centered; }
    }

    : column {
      : edit_box {
        key = "tabaghe_vahed";
        edit_width = 10;
            alignment = centered;
    fixed_width = true;
      }
      : text { label = "ØÈÞå æÇÍÏ"; alignment = centered; }
    }

    : column {
      : edit_box {
        key = "jahate_vahed";
        edit_width = 10;
               alignment = centered;
    fixed_width = true;
      }
      : text { label = "ÌåÊ æÇÍÏ"; alignment = centered; }
    }
      
      }

 : spacer { width = 0.6; fixed_width = true;  }
 :row{
 width = 80;
 fixed_width = true;
 alignment = centered;
     : image {				//define image tile
          key = "im11" ;				//give it a name
          height = 0.06;			//and a height
          width = 1.0 ;				//and now a width
   	  color = green; 			//set the colour
}
     : image {				//define image tile
          key = "im22" ;				//give it a name
          height = 0.1;			//and a height
          width = 1.0 ;				//and now a width
   	  color = white; 			//set the colour
}


     : image {				//define image tile
          key = "im33" ;				//give it a name
          height = 0.1;			//and a height
          width = 1.0 ;				//and now a width
   	  color = red; 			//set the colour
}


 }
  : spacer { width = 0.6; fixed_width = true;  }

:row{
alignment = right ;
  fixed_width=true;
  : boxed_column {
     label = "ÇØáÇÚÇÊ ãÇá˜";
    children_fixed_height = true ;
    children_fixed_width = true;
    alignment = top ;
    : row {
      : edit_box { key = "name"; width = 25; }
      : spacer {}
      : text { label = "äÇã æ äÇã ÎÇäæÇÏí"; alignment = centered; }
    }

    : row {
      : edit_box { key = "father_name"; width = 25; }
      : spacer {}
      : text { label = "äÇã ÏÑ"; alignment = centered; }
    }

    : row {
      : edit_box { key = "personal_code"; width = 25; edit_limit = 10; }
      : spacer {}
      : text { label = "˜Ï ãáí"; alignment = centered; }
    }

    : row {
      : edit_box { key = "address"; width = 25; }
      : spacer {}
      : text { label = "ÂÏÑÓ"; alignment = centered; }
    }
   : boxed_column {
  alignment = centered;
  height = 2;
  fixed_width = false;

  : row {
    fixed_width = true;
    fixed_height = true;
    alignment = centered;

    : text {
      label = "ÇäÏÇÒå ãÊä";
      alignment = centered;
      vertical_margin = none;
    }
    : edit_box {
      key = "txt_size";
      edit_width = 5;
      fixed_width = true;
      alignment = centered;
      vertical_margin = none;
    }
: image_button {
  key = "txt-pik";
  width = 3.5;
  aspect_ratio= 1.0 ;

}

  }
}


  }

  : boxed_column {
    children_fixed_width = true;
  fixed_width=true;
    label = "ÇØáÇÚÇÊ ãÌÑí";   

    : row {
      : edit_box { key = "company_name"; width =25;  }
      : spacer {}
      : text { label = "äÇã ÔјÊ"; alignment = centered; }
    }

    : row {
      : edit_box { key = "boss_name"; width = 25; }
      : spacer {}
      : text { label = "äÇã ãÏíÑ ÚÇãá"; alignment = centered;}
    }

    : row {
      : edit_box { key = "melli_code"; width = 25; edit_limit = 10; }
      : spacer {}
      : text { label = "˜Ï ãáí"; alignment = centered; }
    }

    : row {
      : edit_box { key = "shomare_parvaneh"; width = 25; }
      : spacer {}
      : text { label = "ÔãÇÑå ÑæÇäå"; alignment = centered; }
    }

    : row {
      : edit_box { key = "shomare_sabt"; width = 25; }
      : spacer {}
      : text { label = "ÔãÇÑå ËÈÊ"; alignment = centered; }
    }

    : row {
      : edit_box { key = "address_mojri"; width = 25; }
      : spacer {}
      : text { label = "ÂÏÑÓ"; alignment = centered; }
    }
  }
}




  spacer;

  // Copyright
  : row {
    alignment = right;
    : text {
      label = "© Mr. Eslami 2025";
      key = "aut";
      alignment = right;
    }
  }

  : row {
    alignment = centered;
    : button { key = "accept"; label = "ÊÃííÏ"; is_default = true; }
    : button { key = "cancel"; label = "ÇäÕÑÇÝ"; is_cancel = true; }
  }
}

yes.

Posted
On 6/2/2025 at 8:36 PM, Lee Mac said:

Does your DCL file define the appropriate image_button tile with key "txt-pik".

hi bro
could you help me please ?

 

Posted
29 minutes ago, mohammadreza said:

hi bro
could you help me please ?

 

 

Your x & y vector lists are constructed incorrectly.

  • Like 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...