Author Topic: Dimension Control Codes  (Read 3855 times)

0 Members and 1 Guest are viewing this topic.

Dude...Where's My CAD?

  • Guest
Dimension Control Codes
« on: August 20, 2004, 02:12:25 PM »
I am trying to create a lisp that will add text at the end of a default string of dimension text. I found this link regarding control codes:

http://www.cadforum.cz/cadforum_en/qaID.asp?tip=3638

How come the control code "\P" in dimension mtext doesn't work in ACAD 2k2? I need to add a next line variable to my lisp and this was the only strip of code I found.

Ron Heigh

  • Guest
Dimension Control Codes
« Reply #1 on: August 20, 2004, 03:12:45 PM »
Are you using the format "\\P" in your lisp routine to add the \P?
A single \ tells lisp that a switch is about to follow. ie \n=newline
A double \\ indicates that you want \ to display.

Also note:
the "\\P" and "\\X" control characters need to be CAPITALIZED.

AfricaAD

  • Guest
Dimension Control Codes
« Reply #2 on: August 20, 2004, 03:37:28 PM »
I think he means that adding "\P" in dimension text or mtext doesn't work. I know mine doesn't. Is there a variable for it?

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Dimension Control Codes
« Reply #3 on: August 20, 2004, 03:55:52 PM »
I'm guessing Ron is right, I think they want to add another line of text under the dim. try this.
Code: [Select]

(setq entlst (entget (car (entsel "\nSelect Dim: "))))

(setq entlst
  (subst
(cons 1 "<>\\Psecond line")
(assoc 1 entlst)
entlst
)
 )

(entmod entlst)
TheSwamp.org  (serving the CAD community since 2003)

Ron Heigh

  • Guest
Dimension Control Codes
« Reply #4 on: August 20, 2004, 04:52:25 PM »
\P doesn't put a new line in your mtext editor.
It puts a new line in your lisp programming.
You just hit enter to add a new line in your mtext editor.

Ron Heigh

  • Guest
Dimension Control Codes
« Reply #5 on: August 20, 2004, 04:56:23 PM »
Here is a program to do what your are looking for.

Save as DimNote.lsp

Code: [Select]
;; ======================================================
;; Dimension Note - add a modifier note to an existing
;;                  associative dimension string.
;;
;; Copyright 1999, Mike Lapinski
;;
;; Permission to use, copy, modify, and distribute this software
;; for any purpose and without fee is hereby granted, provided
;; that the above copyright notice appears in all copies and
;; that both that copyright notice and the limited warranty
;; notice below appear in all supporting documentation.
;;
;; D I S C L A I M E R   O F   W A R R A N T Y
;; ======================================================
;;
;; THIS PROGRAM IS MADE AVAILABLE ON AN "AS IS" BASIS WITHOUT
;; WARRANTIES AS TO PERFORMANCE OF MERCHANTABILITY OR ANY
;; OTHER WARRANTIES WHETHER EXPRESSED OR IMPLIED. I DO NOT
;; WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
;; UNINTERRUPTED OR ERROR FREE.
;;
;; I SHALL UNDER NO CIRCUMSTANCE BE LIABLE FOR ANY DAMAGES,
;; INCLUDING BUT NOT LIMITED TO; LOSS OF PROFITS, LOSS OF TIME,
;; LOSS OF DATA OR BUSINESS INTERRUPTION RESULTING FROM THE USE
;; OF THE INABILITY TO USE THIS SOFTWARE. THE USER MUST ASSUME
;; THE ENTIRE RISK OF USING THE PROGRAM.
;;
;; C O P Y R I G H T   N O T I C E   A N D   T R A D E M A R K S
;; =============================================================
;;
;; This program is copyrighted with all rights reserved by
;; Michael Lapinski. This program is for "PUBLIC DOMAIN" use
;; and may not be marketed or offered for sale to others.
;;
;;======================================================
;; Function: DN_ShowNote
;; Purpose:  Show note selected from ListBox in EditBox
;;======================================================
(defun DN_ShowNote (/ lnum lnote)
(set_tile "error" "")
(setq lnum  (get_tile "lb_notes")
      lnote (nth (atoi lnum) dm_notes)
)
(set_tile "eb_note" lnote)
(princ)
)
;;======================================================
;; Function: DN_PlaceNote
;; Purpose:  If valid note is input, close dialog box
;;======================================================
(defun DN_PlaceNote ()
(set_tile "error" "")
(setq dn_modifier (get_tile "eb_note"))
(if (= dn_modifier " ")
    (set_tile "error" "Invalid note string")
    (done_dialog 1)
)    
)
;;======================================================
;; Function: DN_AppendNote
;; Purpose:  Append note to selected dimension entity
;;======================================================
(defun DN_AppendDim (val placement / ent dval)
(setq ent (car (entsel "\nSelect dimension for note: " )))
(while (/= "DIMENSION" (cdr (assoc 0 (entget ent))))
       (princ "\nSelected entity is not a DIMENSION.")
       (setq ent (car (entsel "\nSelect dimension for note: ")))
);while
(setq ent  (entget ent)
      dval (cdr (assoc 1 ent))
)
(if (= dval "")
    (setq dval "<>")
)
(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))
      )
     )    
)
(entmod (subst (cons 1 val)(assoc 1 ent) ent))
(princ)
)
;;======================================================
;; Main Function - Dimension NOTE
;;======================================================
(defun C:DNOTE (/ dcl_id dm_notes dn_above)

  ;enumerate this routine
  (IF (= nil id:lispold)
    (setq id:lispold "x")
    (setq id:lispold id:lisp))
  (setq id:lisp "DimNote.lsp")
  (c:counter)

(setq dcl_id (load_dialog "dimnote.dcl"))
(if (not (new_dialog "dimnote" dcl_id))(exit))
(setq dm_notes '("CLR." "CLEAR" "MIN." "MAX."
                 "R.O." "(REF)" "TYP." "TYPICAL" "V.I.F."
                 "VERIFY IN FIELD"
                )
      dn_above   0
)
(set_tile "eb_note" "(REF)")
(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)
)
(unload_dialog dcl_id)
(princ)
)
(princ "\nDNOTE Loaded...")
(princ)


*************************************************
save as DimNote.dcl

Code: [Select]
//
// Dimension Note - add a modifier note to an existing
//                  associative dimension string.
//
// Copyright 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 = "Locate Below Dimension";
                    mnemonic = "B";
                    key = "dn_below";
            }
            : radio_button {
                    label = "Locate Next to Dimension";
                    mnemonic = "N";
                    key = "dn_above";
            }

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


HTH, Ron

daron

  • Guest
Dimension Control Codes
« Reply #6 on: August 23, 2004, 09:02:11 AM »
This thread has been moved by me. You may now return back to your regular programming.