Author Topic: I need help with a lisp  (Read 1962 times)

0 Members and 1 Guest are viewing this topic.

ELOQUINTET

  • Guest
I need help with a lisp
« on: August 10, 2006, 04:42:47 PM »
We have several lisp routines for adding text to dimensions. We have many variations of this but no matter how many we develop there always seems to be another needed every now and then. What I would like is to allow the user to specify whatever text that need to put then it will add it. in other words I wanna make it open ended for the infrequent text we use. Can somebody help me out with this?


Code: [Select]
(defun c:DRE ()
  (setq dialog (getvar "CMDDIA"))
    (setvar "CMDDIA" 0)
      (setq txt1 "<>"
            txt2 "XD.E."
            txt (strcat txt1 (chr 092) txt2 )
      )
      (setq dims (ssget))
      (command "dimedit" "N" txt dims "" "dimedit" "H" "P" "")
  (setvar "CMDDIA" dialog)
(princ)
)

T.Willey

  • Needs a day job
  • Posts: 5251
Re: I need help with a lisp
« Reply #1 on: August 10, 2006, 05:28:49 PM »
You want to add text to below the dim line, but you want the user to be able to type in what they want?  If that is the case, then maybe this will work for you.

Code: [Select]
(defun c:AddUnderDim (/ Str ss cnt Ent EntData)

(if
 (and
  (/= (setq Str (getstring T"\n Enter text to place under dimension text: ")) "")
  (setq ss (ssget '((0 . "DIMENSION"))))
  (setq cnt -1)
 )
 (while (setq Ent (ssname ss (setq cnt (1+ cnt))))
  (setq EntData (entget Ent))
  (entupd
   (cdr
    (assoc -1
     (entmod
      (subst (cons 1 (strcat "<>\\X" Str)) (assoc 1 EntData) EntData)
     )
    )
   )
  )
 )
)
(princ)
)
     
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

ELOQUINTET

  • Guest
Re: I need help with a lisp
« Reply #2 on: August 11, 2006, 09:18:20 AM »
Thanks man works good. The only modification i needed to make was to send the dimension home at the end like so and it does exactly what I wanted I appreciate your help


Code: [Select]
     )
    )
   )
  )
 )
)
    (command "dimedit" "N" txt dims "" "dimedit" "H" "P" "")
(princ)
)



Dan

T.Willey

  • Needs a day job
  • Posts: 5251
Re: I need help with a lisp
« Reply #3 on: August 11, 2006, 11:00:44 AM »
You're welcome.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

delium55

  • Guest
Re: I need help with a lisp
« Reply #4 on: August 11, 2006, 11:45:31 AM »
 You can try this one.

Code: [Select]
;Tip1566A:  DIMNOTE.LSP   Dimension Notes   (c)1999, Mike Lapinski

(defun DN_SHOWNOTE (/ LNUM LNOTE)
  (set_tile "error" "")
  (setq LNUM  (get_tile "lb_notes")
        LNOTE (nth (atoi LNUM) DM_NOTES)
  ) ;_ end of setq
  (set_tile "eb_note" LNOTE)
  (princ)
) ;_ end of defun
;;======================================================
;; Function: DN_PlaceNote
;; Purpose:  If valid note is input, close dialog box
;;======================================================
(defun DN_PLACENOTE ()
  (set_tile "error" "")
  (setq DN_MODIFIER (strcase (get_tile "eb_note")))
  (if (= DN_MODIFIER " ")
    (set_tile "error" "Invalid note string")
    (done_dialog 1)
  ) ;_ end of if
) ;_ end of defun
;;======================================================
;; Function: DN_AppendNote
;; Purpose:  Append note to selected dimension entity
;;======================================================
(defun DN_APPENDDIM (VAL PLACEMENT / ENT DVAL)
  (setq ENT (car (entsel "\nSelectionné dimension pour annotation: ")))
  (while (/= "DIMENSION" (cdr (assoc 0 (entget ENT))))
    (princ "\nSelected entity is not a DIMENSION.")
    (setq ENT (car (entsel "\nSelectionné dimension pour annotation: ")))
  ) ;while
  (setq ENT  (entget ENT)
        DVAL (cdr (assoc 1 ENT))
  ) ;_ end of setq
  (if (= DVAL "")
    (setq DVAL "<>")
  ) ;_ end of if
  (if (= PLACEMENT 1) ;above line
    (setq VAL (strcat DVAL " " VAL))
    (progn
      (if (wcmatch DVAL "*\\X*")
        (setq VAL (strcat DVAL "\\P" VAL))
        (setq VAL (strcat DVAL "\\X" VAL))
      ) ;_ end of if
    ) ;_ end of progn
  ) ;_ end of if
  (entmod (subst (cons 1 VAL) (assoc 1 ENT) ENT))
  (princ)
) ;_ end of defun
;;======================================================
;; Main Function - Dimension NOTE
;;======================================================
(defun C:DNOTE (/ DCL_ID DM_NOTES DN_ABOVE)
  (setq DCL_ID (load_dialog "dimnote.dcl"))
  (if (not (new_dialog "dimnote" DCL_ID))
    (exit)
  ) ;_ end of if
  (setq DM_NOTES '("AGRANDISSEMENT" "CLR." "D.C." "DÉPART DE COTE" "EXISTANT" "FIN DE PONTAGE" "MIN." "MAX." "N.A.E."
                  "NON À L'ÉCHELLE" "O.B." "OUVERTURE BRUTE" "REF." "S.I.C." "SAUF INDICATION CONTRAIRE"
                  "TYP." "TYPIQUE" "VÉRIFIER AU CHANTIER"
                  )
        DN_ABOVE 0
  ) ;_ end of setq
  (set_tile "eb_note" "TYP.")
  (set_tile "dn_below" "1") ; Set as default
  (start_list "lb_notes")
  (mapcar 'add_list DM_NOTES)
  (end_list)
  (set_tile "lb_notes" "7")
  (action_tile "lb_notes" "(DN_ShowNote)")
  (action_tile "dn_above" "(setq dn_above 1)")
  (action_tile "dn_below" "(setq dn_above 0)")
  (action_tile "accept" "(DN_PlaceNote)")
  (action_tile "cancel" "(done_dialog 0)")
  (if (eq (start_dialog) 1)
    (DN_APPENDDIM DN_MODIFIER DN_ABOVE)
  ) ;_ end of if
  (unload_dialog DCL_ID)
  (princ)
) ;_ end of defun

(princ "Chargé en tapant DNOTE  ")
*******************************************************

//Tip1566B:  DIMNOTE.DCL   Dimension Notes   (c)1999, Mike Lapinski

dimnote : dialog {
    label = "Dimension Notes";
    initial_focus = eb_note;
            : list_box {
                label = "Notes";
                mnemonic = "o";
                key = "lb_notes";
                height = 11;
            }
           : radio_column {
                fixed_width = true;
            : radio_button {
                    label = "Localisé sous ligne de cote";
                    mnemonic = "B";
                    key = "dn_below";
            }
            : radio_button {
                    label = "Localisé à côté de la cote";
                    mnemonic = "N";
                    key = "dn_above";
            }

           }
            : edit_box {
                label = "Note:";
                key = "eb_note";
                horizontal_alignment = left;
            }
    spacer;
    ok_cancel;
    errtile;
}


EDIT: Wrapped that up in [ code ] tags for ya
« Last Edit: August 11, 2006, 11:59:11 AM by nivuahc »