Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/27/2023 in all areas

  1. Try this: ;;Draw leader and text inside circle (DEFUN C:LEADBBL (/ *error* _Common _Getkword ACD BOX C67 CLA CTB DIA DIC DIS DMC DMH DMS DMY DSO FDS FIL LDI POS PT1 PT2 PT3 PTE PTW RAD RGT SRT TXT ) (defun *error* (s) (if (and PT2 (not PT3)) (redraw)) (if (and ACD DSO DMS) (vla-put-activedimstyle ACD (vla-item DIC DMS))) (if DIC (vlax-release-object DIC)) (if ACD (vlax-release-object ACD)) (or (wcmatch (strcase s) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\nError: " s))) (princ) ) (defun _Common (nume) (mapcar (function cons) (quote (0 100 67 410 8)) (list nume "AcDbEntity" C67 CTB CLA) ) ) (defun _Getkword (Ini Def Esc Msg / lies lopt noli stop) (prompt Msg) (setq lies (list (quote (2 13)) (quote (2 32))) Ini (mapcar (function (lambda (x) (list 2 (ascii x)))) Ini) ) (while (not stop) (setq noli (vl-catch-all-error-p (setq lopt (vl-catch-all-apply (function grread) (list nil 8)))) stop (cond ( noli Esc) ( (or (= (car lopt) 25) (vl-position lopt lies)) Def) ( (vl-position lopt Ini) (princ (chr (cadr lopt)))) ( T (if (= (car lopt) 2) (princ (chr (cadr lopt)))) (prompt (strcat "\nInvalid option." Msg))) ) ) ) (strcase stop) ) (setq CTB (if (= (getvar "CVPORT") 1) (getvar "CTAB") "Model") C67 (if (= CTB "Model") 0 1) CLA (getvar "CLAYER") DMS (getvar "DIMSTYLE") ACD (vla-get-activedocument (vlax-get-acad-object)) DIC (vla-get-dimstyles ACD) FIL (vl-filename-mktemp (substr (rtos (getvar "CDATE") 2 8) 10) nil ".tmp") ) (vlax-for itm DIC (setq LDI (cons (vla-get-name itm) LDI))) (setq LDI (acad_strlsort LDI)) (if (= (_Getkword (quote ("n" "N" "y" "Y")) "N" "N" (strcat "\nCurrent Dimension Style \"" DMS "\" settings will be used. Select another Dimension Style [Yes/No] <No>: ")) "Y") (if (setq FDS (open FIL "w")) (progn (write-line (strcat "DimStyle:dialog{label=\"Dimension Style selection\";initial_focus=\"Dims\";:row{:boxed_row{label=\"Available Dimension Styles\";:list_box{key=\"Dims\";height=8;width=" (itoa (+ (apply (function max) (mapcar (function strlen) LDI)) 2)) ";}}:column{alignment=bottom;fixed_height=true;:button{label=\"&OK\";key=\"DoIt\";is_default=true;width=14;fixed_width=true;height=2;}:spacer{height=0.25;}:button{label=\"&Cancel\";key=\"Cancel\";is_cancel=true;width=14;fixed_width=true;height=2;}}}}" ) FDS ) (setq FDS (close FDS) DIA (load_dialog FIL) POS (itoa (vl-position DMS LDI)) ) (new_dialog "DimStyle" DIA) (start_list "Dims") (foreach el LDI (add_list el)) (end_list) (set_tile "Dims" POS) (action_tile "Dims" "(setq POS $value)") (action_tile "DoIt" "(done_dialog 1)") (action_tile "Cancel" "(done_dialog 0)") (setq SRT (start_dialog)) (unload_dialog DIA) (vl-file-delete FIL) (if (and (= SRT 1) (/= (vl-position DMS LDI) (atoi POS))) (progn (setq DSO (nth (atoi POS) LDI)) (vla-put-activedimstyle ACD (vla-item DIC DSO)) ) ) ) (alert (strcat "Unable to write data to folder \"" (vl-filename-directory FIL) "\". Current Dimension Style \"" DMS "\" settings will be used.")) ) ) (setq DMC (getvar "DIMCLRD") DMH (getvar "DIMTXT") DMY (getvar "DIMTXSTY") ) (initget 1) (setq PT1 (getpoint "\nLeader start point: ")) (initget 1) (setq PT2 (getpoint PT1 "\nLeader second point: ")) (grdraw PT1 PT2 (if (vl-position DMC (quote (0 256))) (vla-get-color (vla-item (vla-get-layers ACD) CLA)) DMC)) (initget 1) (setq PT3 (getpoint PT2 "\nX coordinate of the Leader last point: ") DIS (distance PT2 (list (car PT3) (cadr PT2) (caddr PT2))) PTE (polar PT2 0 DIS) PTW (polar PT2 pi DIS) RGT (< (car PT2) (car PT3)) ) (redraw) (entmake (append (_Common "LEADER") (list (cons 62 DMC) (quote (100 . "AcDbLeader")) (cons 3 (cond (DSO) (DMS))) (cons 10 PT1) (cons 10 PT2) (cons 10 (if RGT PTE PTW)) ) ) ) (if (and (setq TXT (getstring T "\nAnnotation text: ")) (vl-remove 32 (vl-string->list TXT)) ) (progn (setq BOX (textbox (list (cons 1 TXT) (cons 7 DMY) (cons 40 DMH))) RAD (fix (+ 0.5 (max 0.5 (* 0.9 DMH) (* 0.525 (distance (car BOX) (cadr BOX)))))) PT1 (if RGT (polar PTE 0 RAD) (polar PTW pi RAD)) ) (entmake (append (_Common "CIRCLE") (list (cons 62 DMC) (quote (100 . "AcDbCircle")) (cons 10 PT1) (cons 40 RAD) ) ) ) (entmake (append (_Common "TEXT") (list (cons 62 (getvar "DIMCLRT")) (quote (100 . "AcDbText")) (cons 10 PT1) (cons 40 DMH) (cons 1 TXT) (quote (50 . 0.)) (cons 41 (vla-get-width (vla-item (vla-get-textstyles ACD) DMY))) (quote (51 . 0.)) (cons 7 DMY) (quote (71 . 0)) (quote (72 . 1)) (cons 11 PT1) (quote (73 . 2)) ) ) ) ) ) (if DSO (vla-put-activedimstyle ACD (vla-item DIC DMS))) (vlax-release-object DIC) (vlax-release-object ACD) (princ) ) ;;C:LEADBBL
    2 points
  2. You should check the validity of the arguments prior to passing them to my function - how are you obtaining the data?
    1 point
  3. I just do Osnap set the snaps I want to use then get a Pencil you know that thing that marks paper, then type OSMODE write down the number.
    1 point
  4. ahh., forgot, have to remove the get points part of the second lisp - will have a look next week, remind me
    1 point
  5. Sometimes it can be as simple as chain the correct sequence of commands, did not look very hard at code. Lots of code (c:offsec) (c:2)
    1 point
  6. Can this be achieved ?. It can be very practical when pipes needs to be denser near windows and outer walls. p.s. is there an easy way to modify existing one ?
    1 point
×
×
  • Create New...