Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/02/2024 in all areas

  1. You can add simply after line 27 a new line with: (ssdel sn s)
    2 points
  2. Would also bring up that using generic block names between drawings that get modified in the drawing itself could bring issues. I worked in production and our projects would be exported to CNC. for speed we used blocks that stored shapes and depth. everything could be exported to a spread sheet and updated there and then imported back into the drawing. when someone said part of project x is in project y we would open Y copy the section we needed and paste into the new project. problem is if the Block A was already defined in the new project it wouldn't bring over Block A from the old project it would bring the insertion put but use the block reference that is already in the new drawing. if their was any difference between the two block's depth or shape difference it would just bring everything over and not throw an error or say anything about changes. and I didn't know anything was different when this happened. the shape was the same but depth info was almost 2" difference. required additional machining and a "investigation" on why this happened (setq myblks '("BlockA" "BlockB" "BlockC")) (foreach blk myblks (if (tblsearch "BLOCK" blk) (prompt (strcat "\n" blk " Found")) ) )
    1 point
  3. So in your cond I don't think you need the 'if', it should run through until it finds the first condition that is true - in this case if you have BlockA and BlockC it will insert Block1 and not Block3... you can order your inserts in order of priority. You might also consider a 'T' condition - if none of the above conditions are met, do "T" (defun c:foo () (cond ((tblsearch "BLOCK" "BlockA") (command "-insert" "Block1" "0,0" "" "" "") ) ((tblsearch "BLOCK" "BlockB") (command "-insert" "Block2" "0,0" "" "" "") ) ((tblsearch "BLOCK" "BlockC") (command "-insert" "Block3" "0,0" "" "" "") ) ) (princ) ) (tablesearch "block") will return a list of all the blocks in the drawing, you can search this using "member" and the block name (tblsearch will return just the specified block if it exists)
    1 point
  4. And if you internationalize the parameters of (osnap) "cen" -> "_cen" "near" -> "_near" This might work! Otherwise you can try this: (defun c:set_fillet ( / ent dxf_ent typ_ent mkv vector vlaobj id_rad) (while (not (setq ent (entsel "Select curve to set Fillet Radius: ")))) (setq typ_ent (cdr (assoc 0 (setq dxf_ent (entget (car ent)))))) (cond ((or (eq typ_ent "ARC") (eq typ_ent "CIRCLE") (eq typ_ent "LWPOLYLINE") (and (eq typ_ent "POLYLINE") (zerop (boole 1 120 (cdr (assoc 70 dxf_ent)))) ) ) (if (or (> (fix (car (trans (cadr ent) 1 0))) 1E6) (> (fix (cadr (trans (cadr ent) 1 0))) 1E6)) (setq mkv T vector (trans (cadr ent) 0 0 T) vlaobj (vlax-ename->vla-object (car ent))) (setq mkv nil) ) (if mkv (vla-move vlaobj (vlax-3d-point (trans (cadr ent) 1 0)) (vlax-3d-point '(0.0 0.0 0.0)))) (setq id_rad (distance '(0 0) (trans (vlax-curve-getsecondderiv (car ent) (vlax-curve-getparamatpoint (car ent) (vlax-curve-getclosestpointto (car ent) (if mkv '(0.0 0.0 0.0) (trans (cadr ent) 1 0))) ) ) 0 (car ent) T ) ) ) (if mkv (vla-move vlaobj (vlax-3d-point '(0.0 0.0 0.0)) (vlax-3d-point vector))) (setvar "FILLETRAD" (abs id_rad)) ) (T (setvar "FILLETRAD" 0.0)) ) (command "_.fillet" "_multiple") (prin1) )
    1 point
  5. A quick example written from Mobile. (setq obj (car (entsel "\nSelect circle:"))) (setvar 'filletrad (cdr(assoc 40 (entget obj))))
    1 point
  6. I will double check what is posted is Ok. Found a command TJUST that should work in Acad and Bricscad. If not working Acad use _.justifytext. (command "TJUST" ss "" "MC") Found a problem in the while fixed that. Hopefully correct now. Did a little bit of reorganising code also. Just did 3 columns of text worked ok. ; https://www.cadtutor.net/forum/topic/88262-mtext-align-and-mtext-width-0/ ; simple align text to line : By AlanH July 2024 ;;; Justification Macros ;;; ;;; https://www.cadtutor.net/forum/topic/35569-text-justification-lisp/?do=findComment&comment=289008 ;;; ;;; BY alanjt (a.k.a. Alan J. Thompson) ;;; ;;; Customized By SLW210 ;;; (defun c:alt1 ( / _justifyIt ent fo x Y k ans but ss oldsnap pt obj ptn) (defun _justifyIt (justify title / ) (princ (strcat "\nSelect *Text to " title " justify: ")) (if (setq ss (ssget '((0 . "ATTDEF,MTEXT,TEXT")))) (command "_.TJUST" ss "" justify) ) (princ) ) (while (setq ent (car (entsel "\nPick single text for alignment Enter to exit "))) (if (= fname nil) (progn (setq fo (open (setq fname (vl-filename-mktemp "" "" ".dcl")) "w")) (write-line "AHtxtpos : dialog {" fo) (write-line " label =\"Please Choose \" ;" fo) (write-line " : column {" fo) (write-line " : boxed_radio_row {" fo) (write-line " width = 24 ;" fo) (write-line " : radio_button {" fo) (write-line "key = \"Rb1\";" fo) (write-line "label = \"Top L\";" fo) (write-line " }" fo) (write-line " : radio_button {" fo) (write-line "key = \"Rb2\";" fo) (write-line "label = \"Top Mid\";" fo) (write-line " }" fo) (write-line " : radio_button {" fo) (write-line "key = \"Rb3\";" fo) (write-line "label = \"Top R\";" fo) (write-line " }" fo) (write-line " }" fo) (write-line "spacer_1 ;" fo) (write-line " : boxed_radio_row {" fo) (write-line " : radio_button {" fo) (write-line "key = \"Rb4\";" fo) (write-line "label = \"Mid L\";" fo) (write-line " }" fo) (write-line " : radio_button {" fo) (write-line "key = \"Rb5\";" fo) (write-line "label = \"Center\";" fo) (write-line " }" fo) (write-line " : radio_button {" fo) (write-line "key = \"Rb6\";" fo) (write-line "label = \"Mid R\";" fo) (write-line " }" fo) (write-line " }" fo) (write-line "spacer_1 ;" fo) (write-line " : boxed_radio_row {" fo) (write-line " : radio_button {" fo) (write-line "key = \"Rb7\";" fo) (write-line "label = \"Bot L \";" fo) (write-line " }" fo) (write-line "spacer_1 ;" fo) (write-line " : radio_button {" fo) (write-line "key = \"Rb8\";" fo) (write-line "label = \"Bot mid\";" fo) (write-line " }" fo) (write-line " : radio_button {" fo) (write-line "key = \"Rb9\";" fo) (write-line "label = \"Bot R\";" fo) (write-line " }" fo) (write-line " }" fo) (write-line "spacer_1 ;" fo) (write-line " ok_cancel;" fo) (write-line " }" fo) (write-line " }" fo) (close fo) ) ) (setq dcl_id (load_dialog fname)) (if (not (new_dialog "AHtxtpos" dcl_id) ) (exit) ) (set_tile "Rb1" "1") (setq x 1) (repeat 9 (setq k (strcat "Rb" (rtos x 2 0))) (action_tile k (strcat "(setq but " (rtos x 2 0) ")" "(done_dialog)")) (setq x (+ x 1)) ) (action_tile "accept" "(done_dialog)") (start_dialog) (unload_dialog dcl_id) (cond ((= but 1)(_justifyIt "_TL" "Top Left")) ((= but 2)(_justifyIt "_TC" "Top Center")) ((= but 3)(_justifyIt "_TR" "Top Right")) ((= but 4)(_justifyIt "_ML" "Middle Left")) ((= but 5)(_justifyIt "_MC" "Middle Center")) ((= but 6)(_justifyIt "_MR" "Middle Right")) ((= but 7)(_justifyIt "_BL" "Bottom Left")) ((= but 8)(_justifyIt "_BC" "Bottom Center")) ((= but 9)(_justifyIt "_BR" "Bottom Right")) ) (if (not AH:Butts)(load "Multi Radio buttons.lsp")) (if (= ahdef nil)(setq ahdef 1)) (setq oldsnap (getvar 'osmode)) (setvar 'osmode 0) (setq ans (ah:butts ahdef "h" '("Horizontal or vertical " "Hor " "Ver"))) ; ans holds the button picked value (setq ahdef but) (setq pt (cdr (assoc 10 (entget ent)))) (setq X (car pt) Y (cadr pt)) (if (= ss nil) (progn (alert "You have not selected anything will now exit")(exit)) ) (repeat (setq k (sslength ss)) (setq obj (vlax-ename->vla-object (ssname ss (setq k (- k 1))))) (setq ptn (vlax-get obj 'Insertionpoint)) (if (= ahdef 1) (setq ptn (list (car ptn) Y 0.0)) (setq ptn (list X (cadr ptn) 0.0)) ) (vlax-put obj 'insertionpoint ptn) ) ; repeat ) ; while (vl-file-delete fname) (setvar 'osmode oldsnap) (princ) ) (C:alt1) Re Error message got similar at another post, forums/autodesk, I think it may be I am using Bricscad and it may accept X,Y as a point but Acad wants X,Y,Z. I have added the z=0 to pnt please let me know if that fixes it.
    1 point
  7. Maybe just wblock out some bits and insert into a single sample dwg. You can use the dcl above then only need 1 defun command for justification pick. Maybe write the dcl and save, then no need to continually write it just change the mk-temp to a file name. May speed up things. Had another go pick a single text as the reference, then select all text, input Vertical or Horizontal. One issue was where I picked a point and moved others but they had different justifications. (defun c:alt1 ( / ss x Y k ans) (if (not AH:Butts)(load "Multi Radio buttons.lsp")) (if (= ahdef nil)(setq ahdef 1)) (setq oldsnap (getvar 'osmode)) (setvar 'osmode 0) (while (setq ent (car (entsel "\nPick text for alignment reference point Enter to exit "))) (setq ans (ah:butts ahdef "h" '("Horizontal or vertical " "Hor " "Ver"))) ; ans holds the button picked value (setq ahdef but) (setq pt (cdr (assoc 10 (entget ent)))) (setq X (car pt) Y (cadr pt)) (prompt "\nSelect text ") (setq ss (ssget '((0 . "*TEXT")))) (if (= ss nil) (progn (alert "You have not selected anything will now exit")(exit)) ) (repeat (setq k (sslength ss)) (setq obj (vlax-ename->vla-object (ssname ss (setq k (- k 1))))) (setq ptn (vlax-get obj 'Insertionpoint)) (if (= ahdef 1) (setq Ptn (list (car ptn) Y )) (setq Ptn (list X (cadr ptn))) )m (vlax-put obj 'insertionpoint ptn) ) ) (setvar 'osmode 0) (princ) ) (C:alt1) Multi radio buttons.lsp The multi radio should remember last Hor or ver, so can do enter if it doesn't let me know was a bug in a version I posted here. Still thinking about auto Ver or Hor.
    1 point
  8. Had another go this may be useful for justification. (defun wow ( / fo dcl_id fname x) (setq fo (open (setq fname (vl-filename-mktemp "" "" ".dcl")) "w")) (write-line "AHtxtpos : dialog {" fo) (write-line " label =\"Please Choose \" ;" fo) (write-line " : column {" fo) (write-line " : boxed_radio_row {" fo) (write-line " width = 24 ;" fo) (write-line " : radio_button {" fo) (write-line "key = \"Rb1\";" fo) (write-line "label = \"Top L\";" fo) (write-line " }" fo) (write-line " : radio_button {" fo) (write-line "key = \"Rb2\";" fo) (write-line "label = \"Top Mid\";" fo) (write-line " }" fo) (write-line " : radio_button {" fo) (write-line "key = \"Rb3\";" fo) (write-line "label = \"Top R\";" fo) (write-line " }" fo) (write-line " }" fo) (write-line "spacer_1 ;" fo) (write-line " : boxed_radio_row {" fo) (write-line " : radio_button {" fo) (write-line "key = \"Rb4\";" fo) (write-line "label = \"Mid L\";" fo) (write-line " }" fo) (write-line " : radio_button {" fo) (write-line "key = \"Rb5\";" fo) (write-line "label = \"Center\";" fo) (write-line " }" fo) (write-line " : radio_button {" fo) (write-line "key = \"Rb6\";" fo) (write-line "label = \"Mid R\";" fo) (write-line " }" fo) (write-line " }" fo) (write-line "spacer_1 ;" fo) (write-line " : boxed_radio_row {" fo) (write-line " : radio_button {" fo) (write-line "key = \"Rb7\";" fo) (write-line "label = \"Bot L \";" fo) (write-line " }" fo) (write-line "spacer_1 ;" fo) (write-line " : radio_button {" fo) (write-line "key = \"Rb8\";" fo) (write-line "label = \"Bot mid\";" fo) (write-line " }" fo) (write-line " : radio_button {" fo) (write-line "key = \"Rb9\";" fo) (write-line "label = \"Bot R\";" fo) (write-line " }" fo) (write-line " }" fo) (write-line "spacer_1 ;" fo) (write-line " ok_cancel;" fo) (write-line " }" fo) (write-line " }" fo) (close fo) (setq dcl_id (load_dialog fname)) (if (not (new_dialog "AHtxtpos" dcl_id) ) (exit) ) (set_tile "Rb1" "1") (setq x 1) (repeat 9 (setq k (strcat "Rb" (rtos x 2 0))) (action_tile k (strcat "(setq but " (rtos x 2 0) ")" "(done_dialog)")) (setq x (+ x 1)) ) (action_tile "accept" "(done_dialog)") (start_dialog) (unload_dialog dcl_id) (vl-file-delete fname) (cond ((= but 1)(setq pos "TL")) ((= but 2)(setq pos "TM")) ((= but 3)(setq pos "TR")) ((= but 4)(setq pos "LM")) ((= but 5)(setq pos "Cen")) ((= but 6)(setq pos "RM")) ((= but 7)(setq pos "BL")) ((= but 8)(setq pos "BM")) ((= but 9)(setq pos "BR")) ) (princ) ) (wow)
    1 point
  9. Not sure which text but if its the 1-41 using get-closestpointo should do the trick. You could also select and sort on Y replace X with a fixed value. also replace Y with a fixed increment value. Using a start end point how many etc. I think found some #12/A/IR match yellow line. Tested on the 2 examples and 1-41. ; simple align text to line ; By AlanH July 2024 ; align text option 1 may need alt2 alt3 etc (defun c:alt1 ( / ss x ) (while (setq ent (car (entsel "\nSelect a line object "))) (setq obj (vlax-ename->vla-object ent)) (setq ss (ssget '((0 . "*TEXT")))) (if (= ss nil)(progn (alert "you have not picked any M or text objects \nwill now exit")(exit))) (repeat (setq x (sslength ss)) (setq obj2 (vlax-ename->vla-object (ssname ss (setq x (- x 1))))) (setq pt1 (vlax-get obj2 'insertionpoint )) (setq pt2 (vlax-curve-getclosestpointto obj pt1)) (vla-move obj2 pt1 pt2) ) ) (princ) ) Re alignment problems if you can provide raw text that needs fixing and the options to align. A quick answer is the 9 positions 1-9 for text as a number for me as per image either option probably do a 3x3 dcl. Thinking more if normally Hor or Ver could just select text and use correct X or Y for all text no need for line say use 1st text for that position.
    1 point
×
×
  • Create New...