SLW210 Posted Wednesday at 07:49 PM Posted Wednesday at 07:49 PM My LISP and ClipIt work on nested blocks. I also noticed that the circle in your example drawing was from AutoCAD Mechanical. If you have something that the LISP isn't working on, please post the drawing here so I can see about a fix. I am doing more work on this, specifically some Labelling options. But for now I just have the tangent lines working and made it an option as well as the single line. Let me know how this version is working. ;;; Creates a circular detail clip from a block reference. Copies, scales, and trims to scaled circle (connected by line(s)). ;;; ;;; https://www.cadtutor.net/forum/topic/98334-detail-circle-in-ms/page/3/#findComment-674386 ;;; ;;;************************************************************************************************| ;;; | ;;; By SLW210 (a.k.a. Steve Wilson) | ;;; | ;;; MSCirClip_1.0.lsp | ;;; | ;;; Uses the Express Tool ClipIt manually (maybe this will be automated at a later time). | ;;; At the prompt-Select the detail circle then select the copied and scaled block. | ;;; At Enter maximum allowable error distance for resolution of arc segments. | ;;; I used 1 and it seems good (smaller is more segments) (see Clipit in Express Tools help). | ;;; | ;;;************************************************************************************************| ;;; ClipIt creates a pseudo circle of polylines, the connector line will most likely have a gap. | ;;; | ;;; Added option to delete the detail circle or keep it. | ;;; | ;;; Added option to use a single connector or two tangent lines | ;;; | ;;; | ;;;************************************************************************************************| ;;;************************************************************************************************| ;;; >>> Lee Mac Trigonometric Functions <<< | ;;; | ;;; Tangent - Lee Mac | ;;; Args: x - real | (defun tan (x) (if (not (equal 0.0 (cos x) 1e-10)) (/ (sin x) (cos x)) ) ) ;;; | ;;; ArcCosine - Lee Mac | ;;; Args: -1 <= x <= 1 | (defun acos (x) (if (<= -1.0 x 1.0) (atan (sqrt (- 1.0 (* x x))) x) ) ) ;;; | ;;;************************************************************************************************| (defun c:MSCIRCLIP (/ ent cen rad newPt scaleFactor newRad scaledBlock detailCircle c1 c2 r1 r2 dx dy d ang3 theta ang1 ang2 t1a t1b t2a t2b lineOption vec len dir pt1 pt2 suffix txtHeight txtPoint txtStr delCircle layerTable detailLayer ) (vl-load-com) (prompt "\n--- MODELSPACE DETAIL VIEW WITH CLIPIT ---\n") ;; Ensure DETAIL layer exists and set current (setq detailLayer "DETAIL") (setq layerTable (vla-get-Layers (vla-get-ActiveDocument (vlax-get-acad-object)) ) ) (if (null (tblsearch "LAYER" detailLayer)) (vla-add layerTable detailLayer) ) (setvar 'CLAYER detailLayer) ;; Select block reference (setq ent (car (entsel "\nSelect block reference to detail: "))) (if (not (and ent (= (cdr (assoc 0 (entget ent))) "INSERT"))) (progn (prompt "\nNot a valid block reference.") (exit)) ) ;; Original detail circle (setq cen (getpoint "\nSpecify center of detail circle: ")) (setq rad (getdist cen "\nSpecify radius of detail circle: ")) (entmakex (list '(0 . "CIRCLE") (cons 10 cen) (cons 40 rad) (cons 62 1) (cons 8 detailLayer) ) ) ;; Detail view placement (setq newPt (getpoint "\nSpecify center point for detail view: ")) (initget 7) (setq scaleFactor (getreal "\nEnter detail scale factor (e.g. 2): ")) (setq newRad (* rad scaleFactor)) ;; Copy and scale block (command "COPY" ent "" cen newPt) (setq scaledBlock (entlast)) (command "SCALE" scaledBlock "" newPt scaleFactor) ;; Create clipping circle (temporary) (setq detailCircle (entmakex (list '(0 . "CIRCLE") (cons 10 newPt) (cons 40 newRad) (cons 62 1) (cons 8 detailLayer) ) ) ) ;; Run CLIPIT (prompt "\n>>> Run CLIPIT: Select the detail circle and the new (scaled) block.\n" ) (C:CLIPIT) ;; Connector line (initget "Single Tangents") (setq lineOption (getkword "\nDraw [Single/Tangents] connector line(s)? <Single>: " ) ) (if (null lineOption) (setq lineOption "Single") ) (if (eq lineOption "Single") (progn (setq vec (mapcar '- newPt cen)) (setq len (distance cen newPt)) (setq dir (mapcar '/ vec (list len len len))) (setq pt1 (mapcar '+ cen (mapcar '* dir (list rad rad rad)))) (setq pt2 (mapcar '- newPt (mapcar '* dir (list newRad newRad newRad)) ) ) (entmakex (list '(0 . "LINE") (cons 10 pt1) (cons 11 pt2) (cons 62 3) (cons 8 detailLayer) ) ) ) ;; Tangents (progn (setq c1 cen r1 rad c2 newPt r2 newRad ) (setq dx (- (car c2) (car c1))) (setq dy (- (cadr c2) (cadr c1))) (setq d (sqrt (+ (* dx dx) (* dy dy)))) (if (<= d (abs (- r1 r2))) (prompt "\nCircles too close — no external tangents.\n") (progn (setq ang3 (atan dy dx)) (setq theta (acos (/ (- r1 r2) d))) (setq ang1 (- ang3 theta)) (setq ang2 (+ ang3 theta)) (setq t1a (polar c1 ang1 r1)) (setq t1b (polar c2 ang1 r2)) (setq t2a (polar c1 ang2 r1)) (setq t2b (polar c2 ang2 r2)) (entmakex (list '(0 . "LINE") (cons 10 t1a) (cons 11 t1b) (cons 62 3) (cons 8 detailLayer) ) ) (entmakex (list '(0 . "LINE") (cons 10 t2a) (cons 11 t2b) (cons 62 3) (cons 8 detailLayer) ) ) ) ) ) ) ;; Prompt for deletion (initget "Yes No") (setq delCircle (getkword "\nDelete the scaled detail circle? [Yes/No] <No>: " ) ) (if (eq delCircle "Yes") (progn (if (and detailCircle (entget detailCircle)) (entdel detailCircle) ) ) ) (prompt "\nDetail view created with ClipIt.\n") (princ) ) 1 Quote
jim78b Posted Thursday at 06:46 AM Author Posted Thursday at 06:46 AM 10 hours ago, SLW210 said: My LISP and ClipIt work on nested blocks. I also noticed that the circle in your example drawing was from AutoCAD Mechanical. If you have something that the LISP isn't working on, please post the drawing here so I can see about a fix. I am doing more work on this, specifically some Labelling options. But for now I just have the tangent lines working and made it an option as well as the single line. Let me know how this version is working. ;;; Creates a circular detail clip from a block reference. Copies, scales, and trims to scaled circle (connected by line(s)). ;;; ;;; ;;; ;;;************************************************************************************************| ;;; | ;;; By SLW210 (a.k.a. Steve Wilson) | ;;; | ;;; MSCirClip_1.0.lsp | ;;; | ;;; Uses the Express Tool ClipIt manually (maybe this will be automated at a later time). | ;;; At the prompt-Select the detail circle then select the copied and scaled block. | ;;; At Enter maximum allowable error distance for resolution of arc segments. | ;;; I used 1 and it seems good (smaller is more segments) (see Clipit in Express Tools help). | ;;; | ;;;************************************************************************************************| ;;; ClipIt creates a pseudo circle of polylines, the connector line will most likely have a gap. | ;;; | ;;; Added option to delete the detail circle or keep it. | ;;; | ;;; Added option to use a single connector or two tangent lines | ;;; | ;;; | ;;;************************************************************************************************| ;;;************************************************************************************************| ;;; >>> Lee Mac Trigonometric Functions <<< | ;;; | ;;; Tangent - Lee Mac | ;;; Args: x - real | (defun tan (x) (if (not (equal 0.0 (cos x) 1e-10)) (/ (sin x) (cos x)) ) ) ;;; | ;;; ArcCosine - Lee Mac | ;;; Args: -1 <= x <= 1 | (defun acos (x) (if (<= -1.0 x 1.0) (atan (sqrt (- 1.0 (* x x))) x) ) ) ;;; | ;;;************************************************************************************************| (defun c:MSCIRCLIP (/ ent cen rad newPt scaleFactor newRad scaledBlock detailCircle c1 c2 r1 r2 dx dy d ang3 theta ang1 ang2 t1a t1b t2a t2b lineOption vec len dir pt1 pt2 suffix txtHeight txtPoint txtStr delCircle layerTable detailLayer ) (vl-load-com) (prompt "\n--- MODELSPACE DETAIL VIEW WITH CLIPIT ---\n") ;; Ensure DETAIL layer exists and set current (setq detailLayer "DETAIL") (setq layerTable (vla-get-Layers (vla-get-ActiveDocument (vlax-get-acad-object)) ) ) (if (null (tblsearch "LAYER" detailLayer)) (vla-add layerTable detailLayer) ) (setvar 'CLAYER detailLayer) ;; Select block reference (setq ent (car (entsel "\nSelect block reference to detail: "))) (if (not (and ent (= (cdr (assoc 0 (entget ent))) "INSERT"))) (progn (prompt "\nNot a valid block reference.") (exit)) ) ;; Original detail circle (setq cen (getpoint "\nSpecify center of detail circle: ")) (setq rad (getdist cen "\nSpecify radius of detail circle: ")) (entmakex (list '(0 . "CIRCLE") (cons 10 cen) (cons 40 rad) (cons 62 1) (cons 8 detailLayer) ) ) ;; Detail view placement (setq newPt (getpoint "\nSpecify center point for detail view: ")) (initget 7) (setq scaleFactor (getreal "\nEnter detail scale factor (e.g. 2): ")) (setq newRad (* rad scaleFactor)) ;; Copy and scale block (command "COPY" ent "" cen newPt) (setq scaledBlock (entlast)) (command "SCALE" scaledBlock "" newPt scaleFactor) ;; Create clipping circle (temporary) (setq detailCircle (entmakex (list '(0 . "CIRCLE") (cons 10 newPt) (cons 40 newRad) (cons 62 1) (cons 8 detailLayer) ) ) ) ;; Run CLIPIT (prompt "\n>>> Run CLIPIT: Select the detail circle and the new (scaled) block.\n" ) (C:CLIPIT) ;; Connector line (initget "Single Tangents") (setq lineOption (getkword "\nDraw [Single/Tangents] connector line(s)? <Single>: " ) ) (if (null lineOption) (setq lineOption "Single") ) (if (eq lineOption "Single") (progn (setq vec (mapcar '- newPt cen)) (setq len (distance cen newPt)) (setq dir (mapcar '/ vec (list len len len))) (setq pt1 (mapcar '+ cen (mapcar '* dir (list rad rad rad)))) (setq pt2 (mapcar '- newPt (mapcar '* dir (list newRad newRad newRad)) ) ) (entmakex (list '(0 . "LINE") (cons 10 pt1) (cons 11 pt2) (cons 62 3) (cons 8 detailLayer) ) ) ) ;; Tangents (progn (setq c1 cen r1 rad c2 newPt r2 newRad ) (setq dx (- (car c2) (car c1))) (setq dy (- (cadr c2) (cadr c1))) (setq d (sqrt (+ (* dx dx) (* dy dy)))) (if (<= d (abs (- r1 r2))) (prompt "\nCircles too close — no external tangents.\n") (progn (setq ang3 (atan dy dx)) (setq theta (acos (/ (- r1 r2) d))) (setq ang1 (- ang3 theta)) (setq ang2 (+ ang3 theta)) (setq t1a (polar c1 ang1 r1)) (setq t1b (polar c2 ang1 r2)) (setq t2a (polar c1 ang2 r1)) (setq t2b (polar c2 ang2 r2)) (entmakex (list '(0 . "LINE") (cons 10 t1a) (cons 11 t1b) (cons 62 3) (cons 8 detailLayer) ) ) (entmakex (list '(0 . "LINE") (cons 10 t2a) (cons 11 t2b) (cons 62 3) (cons 8 detailLayer) ) ) ) ) ) ) ;; Prompt for deletion (initget "Yes No") (setq delCircle (getkword "\nDelete the scaled detail circle? [Yes/No] <No>: " ) ) (if (eq delCircle "Yes") (progn (if (and detailCircle (entget detailCircle)) (entdel detailCircle) ) ) ) (prompt "\nDetail view created with ClipIt.\n") (princ) ) In this it don't draw any circle Quote
SLW210 Posted Thursday at 10:16 AM Posted Thursday at 10:16 AM Are you getting errors? You are not being very helpful, can you post a drawing where this isn't working? Also, post the information from your commandline. Works just fine on the drawing you posted. MSCirClip is on the top. Quote
SLW210 Posted Thursday at 10:24 AM Posted Thursday at 10:24 AM Are you using AutoCAD 2022 as your profile shows? 1 Quote
jim78b Posted Friday at 06:47 AM Author Posted Friday at 06:47 AM 20 hours ago, SLW210 said: Are you getting errors? You are not being very helpful, can you post a drawing where this isn't working? Also, post the information from your commandline. Works just fine on the drawing you posted. MSCirClip is on the top. I apologize but apparently I had loaded too many codes in autocad and it didn't work, now it's perfect in my opinion! thank you very much! you are the best code helper! Quote
SLW210 Posted Friday at 10:35 AM Posted Friday at 10:35 AM No apologies needed, glad it worked. Do you need to place text such as "DETAIL-A"? I did have TEXT placed at the bottom center working, when I get back to it, I am working on TOP, BOTTOM, LEFT, RIGHT and use MTEXT as well. Is it working on nested blocks for you now? I did read where ClipIt works on blocks, xrefs, images, and wipeout objects, though I only tested on blocks and nested blocks up to 3 deep. If anybody is interested, I could add option for another shape for clipping ClipIt supports arcs, circles, and polylines. Quote
jim78b Posted Friday at 01:45 PM Author Posted Friday at 01:45 PM (edited) 3 hours ago, SLW210 said: No apologies needed, glad it worked. Do you need to place text such as "DETAIL-A"? I did have TEXT placed at the bottom center working, when I get back to it, I am working on TOP, BOTTOM, LEFT, RIGHT and use MTEXT as well. Is it working on nested blocks for you now? I did read where ClipIt works on blocks, xrefs, images, and wipeout objects, though I only tested on blocks and nested blocks up to 3 deep. If anybody is interested, I could add option for another shape for clipping ClipIt supports arcs, circles, and polylines. only a problem sorry, there is a bug, i don't understand even if i return on layer 0 autocad put me on Layer :DETAIL! at the end of using the lisp it remain on Layer Detail, i want return to layer 0 if possible. if you have time yes it is wonderful if you can add text and other trimming elements. Edited Friday at 01:47 PM by jim78b Quote
SLW210 Posted Friday at 04:25 PM Posted Friday at 04:25 PM I'm off work next week, but will be on the forum some if possible. See how these modifications work for you. Goes back to Layer 0 after putting the new Detail components on DETAIL layer, now has the lines and circles green. ;;; Creates a circular detail clip from a block reference. Copies, scales, and trims to scaled circle (connected by line(s)). ;;; ;;; https://www.cadtutor.net/forum/topic/98334-detail-circle-in-ms/page/3/#findComment-674591 ;;; ;;;************************************************************************************************| ;;; | ;;; By SLW210 (a.k.a. Steve Wilson) | ;;; | ;;; MSCirClip_1.1.lsp | ;;; | ;;; Uses the Express Tool ClipIt manually (maybe this will be automated at a later time). | ;;; At the prompt-Select the detail circle then select the copied and scaled block. | ;;; At Enter maximum allowable error distance for resolution of arc segments. | ;;; I used 1 and it seems good (smaller is more segments) (see Clipit in Express Tools help). | ;;; | ;;;************************************************************************************************| ;;; ClipIt creates a pseudo circle of polylines, the connector line will most likely have a gap. | ;;; | ;;; Added option to delete the detail circle or keep it. | ;;; | ;;; Added option to use a single connector or two tangent lines | ;;; | ;;; Added DETAIL- text with Top, Bottom, option added SCALE:nX below | ;;; | ;;;************************************************************************************************| ;;;************************************************************************************************| ;;; >>> Lee Mac Trigonometric Functions <<< | ;;; | ;;; Tangent - Lee Mac | ;;; Args: x - real | (defun tan (x) (if (not (equal 0.0 (cos x) 1e-10)) (/ (sin x) (cos x)) ) ) ;;; | ;;; ArcCosine - Lee Mac | ;;; Args: -1 <= x <= 1 | (defun acos (x) (if (<= -1.0 x 1.0) (atan (sqrt (- 1.0 (* x x))) x) ) ) ;;; | ;;;************************************************************************************************| (defun c:MSCIRCLIP (/ ent cen rad newPt scaleFactor newRad scaledBlock detailCircle c1 c2 r1 r2 dx dy d ang3 theta ang1 ang2 t1a t1b t2a t2b lineOption vec len dir pt1 pt2 suffix txtHeight txtStr txtPoint txtTemp txtWidth ext labelPos delCircle scaleStr scaleTemp extScale scaleWidth scalePoint scaleHeight offset ) (vl-load-com) (prompt "\n--- CREATE MODELSPACE DETAIL VIEW WITH CLIPIT ---\n") (setq ent (car (entsel "\nSelect block reference to detail: "))) (if (not (and ent (= (cdr (assoc 0 (entget ent))) "INSERT"))) (progn (prompt "\nNot a valid block reference.") (exit)) ) (setq cen (getpoint "\nSpecify center of detail circle: ")) (setq rad (getdist cen "\nSpecify radius of detail circle: ")) (command "_.LAYER" "_Make" "DETAIL" "") (entmakex (list '(0 . "CIRCLE") (cons 10 cen) (cons 40 rad) (cons 62 3) (cons 8 "DETAIL") ) ) (setq newPt (getpoint "\nSpecify center point for detail view: ")) (initget 7) (setq scaleFactor (getreal "\nEnter detail scale factor (e.g. 2): ")) (setq newRad (* rad scaleFactor)) (command "COPY" ent "" cen newPt) (setq scaledBlock (entlast)) (command "SCALE" scaledBlock "" newPt scaleFactor) (setq detailCircle (entmakex (list '(0 . "CIRCLE") (cons 10 newPt) (cons 40 newRad) (cons 62 3) (cons 8 "DETAIL") ) ) ) (prompt "\n>>> Run CLIPIT: Select the detail circle and the new (scaled) block.\n" ) (C:CLIPIT) (initget "Single Tangents") (setq lineOption (getkword "\nDraw [Single/Tangents] connector line(s)? <Single>: " ) ) (if (null lineOption) (setq lineOption "Single") ) (if (eq lineOption "Single") (progn (setq vec (mapcar '- newPt cen)) (setq len (distance cen newPt)) (setq dir (mapcar '/ vec (list len len len))) (setq pt1 (mapcar '+ cen (mapcar '* dir (list rad rad rad)))) (setq pt2 (mapcar '- newPt (mapcar '* dir (list newRad newRad newRad)) ) ) (entmakex (list '(0 . "LINE") (cons 10 pt1) (cons 11 pt2) (cons 62 3) (cons 8 "DETAIL") ) ) ) (progn (setq c1 cen r1 rad c2 newPt r2 newRad ) (setq dx (- (car c2) (car c1))) (setq dy (- (cadr c2) (cadr c1))) (setq d (sqrt (+ (* dx dx) (* dy dy)))) (if (<= d (abs (- r1 r2))) (prompt "\nCircles too close — no external tangents.\n") (progn (setq ang3 (atan dy dx)) (setq theta (acos (/ (- r1 r2) d))) (setq ang1 (- ang3 theta)) (setq ang2 (+ ang3 theta)) (setq t1a (polar c1 ang1 r1)) (setq t1b (polar c2 ang1 r2)) (setq t2a (polar c1 ang2 r1)) (setq t2b (polar c2 ang2 r2)) (entmakex (list '(0 . "LINE") (cons 10 t1a) (cons 11 t1b) (cons 62 3) (cons 8 "DETAIL") ) ) (entmakex (list '(0 . "LINE") (cons 10 t2a) (cons 11 t2b) (cons 62 3) (cons 8 "DETAIL") ) ) ) ) ) ) (setq suffix (getstring t "\nEnter detail label suffix (e.g. A): ")) (setq txtHeight (getreal "\nEnter label text height: ")) (setq scaleHeight (* 0.75 txtHeight)) (setq txtStr (strcat "DETAIL-" (strcase suffix))) ;; TEMP TEXT to measure label width (setq txtTemp (entmakex (list '(0 . "TEXT") (cons 8 "DETAIL") (cons 10 '(0 0 0)) (cons 40 txtHeight) (cons 1 txtStr) (cons 7 "Standard") (cons 72 1) (cons 73 0) ) ) ) (setq ext (textbox (entget txtTemp))) (setq txtWidth (abs (- (car (cadr ext)) (car (car ext))))) (entdel txtTemp) (initget "Top Bottom") (setq labelPos (getkword "\nLabel position? [Top/Bottom] <Bottom>: ")) (if (null labelPos) (setq labelPos "Bottom") ) (setq offset (* 1.75 txtHeight)) (cond ((eq labelPos "Top") (setq txtPoint (list (- (car newPt) (/ txtWidth 2.0)) (+ (cadr newPt) newRad offset) 0 ) ) ) ((eq labelPos "Bottom") (setq txtPoint (list (- (car newPt) (/ txtWidth 2.0)) (- (cadr newPt) (+ newRad offset)) 0 ) ) ) ) ;; Place DETAIL label (entmakex (list '(0 . "TEXT") (cons 8 "DETAIL") (cons 10 txtPoint) (cons 40 txtHeight) (cons 1 txtStr) (cons 7 "Standard") (cons 72 0) (cons 73 0) ) ) ;; SCALE TEXT section (correct height and placement) (setq scaleStr (strcat "SCALE: " (rtos scaleFactor 2 2) "X")) (setq scaleTemp (entmakex (list '(0 . "TEXT") (cons 8 "DETAIL") (cons 10 '(0 0 0)) (cons 40 scaleHeight) (cons 1 scaleStr) (cons 7 "Standard") (cons 72 1) (cons 73 0) ) ) ) (setq extScale (textbox (entget scaleTemp))) (setq scaleWidth (abs (- (car (cadr extScale)) (car (car extScale))))) (entdel scaleTemp) (setq scalePoint (list (- (car newPt) (/ scaleWidth 2.0)) (- (cadr txtPoint) (* 1.1 scaleHeight)) 0 ) ) (entmakex (list '(0 . "TEXT") (cons 8 "DETAIL") (cons 10 scalePoint) (cons 40 scaleHeight) (cons 1 scaleStr) (cons 7 "Standard") (cons 72 0) (cons 73 0) ) ) ;; Option to delete the detail circle (initget "Yes No") (setq delCircle (getkword "\nDelete the scaled detail circle? [Yes/No] <No>: " ) ) (if (eq delCircle "Yes") (entdel detailCircle) ) (command "_.LAYER" "_Set" "0" "") (prompt (strcat "\nDetail view created with ClipIt and " txtStr " label created.\n" ) ) (princ) ) Quote
jim78b Posted Saturday at 06:38 AM Author Posted Saturday at 06:38 AM 14 hours ago, SLW210 said: I'm off work next week, but will be on the forum some if possible. See how these modifications work for you. Goes back to Layer 0 after putting the new Detail components on DETAIL layer, now has the lines and circles green. ;;; Creates a circular detail clip from a block reference. Copies, scales, and trims to scaled circle (connected by line(s)). ;;; ;;; https://www.cadtutor.net/forum/topic/98334-detail-circle-in-ms/page/3/#findComment-674591 ;;; ;;;************************************************************************************************| ;;; | ;;; By SLW210 (a.k.a. Steve Wilson) | ;;; | ;;; MSCirClip_1.1.lsp | ;;; | ;;; Uses the Express Tool ClipIt manually (maybe this will be automated at a later time). | ;;; At the prompt-Select the detail circle then select the copied and scaled block. | ;;; At Enter maximum allowable error distance for resolution of arc segments. | ;;; I used 1 and it seems good (smaller is more segments) (see Clipit in Express Tools help). | ;;; | ;;;************************************************************************************************| ;;; ClipIt creates a pseudo circle of polylines, the connector line will most likely have a gap. | ;;; | ;;; Added option to delete the detail circle or keep it. | ;;; | ;;; Added option to use a single connector or two tangent lines | ;;; | ;;; Added DETAIL- text with Top, Bottom, option added SCALE:nX below | ;;; | ;;;************************************************************************************************| ;;;************************************************************************************************| ;;; >>> Lee Mac Trigonometric Functions <<< | ;;; | ;;; Tangent - Lee Mac | ;;; Args: x - real | (defun tan (x) (if (not (equal 0.0 (cos x) 1e-10)) (/ (sin x) (cos x)) ) ) ;;; | ;;; ArcCosine - Lee Mac | ;;; Args: -1 <= x <= 1 | (defun acos (x) (if (<= -1.0 x 1.0) (atan (sqrt (- 1.0 (* x x))) x) ) ) ;;; | ;;;************************************************************************************************| (defun c:MSCIRCLIP (/ ent cen rad newPt scaleFactor newRad scaledBlock detailCircle c1 c2 r1 r2 dx dy d ang3 theta ang1 ang2 t1a t1b t2a t2b lineOption vec len dir pt1 pt2 suffix txtHeight txtStr txtPoint txtTemp txtWidth ext labelPos delCircle scaleStr scaleTemp extScale scaleWidth scalePoint scaleHeight offset ) (vl-load-com) (prompt "\n--- CREATE MODELSPACE DETAIL VIEW WITH CLIPIT ---\n") (setq ent (car (entsel "\nSelect block reference to detail: "))) (if (not (and ent (= (cdr (assoc 0 (entget ent))) "INSERT"))) (progn (prompt "\nNot a valid block reference.") (exit)) ) (setq cen (getpoint "\nSpecify center of detail circle: ")) (setq rad (getdist cen "\nSpecify radius of detail circle: ")) (command "_.LAYER" "_Make" "DETAIL" "") (entmakex (list '(0 . "CIRCLE") (cons 10 cen) (cons 40 rad) (cons 62 3) (cons 8 "DETAIL") ) ) (setq newPt (getpoint "\nSpecify center point for detail view: ")) (initget 7) (setq scaleFactor (getreal "\nEnter detail scale factor (e.g. 2): ")) (setq newRad (* rad scaleFactor)) (command "COPY" ent "" cen newPt) (setq scaledBlock (entlast)) (command "SCALE" scaledBlock "" newPt scaleFactor) (setq detailCircle (entmakex (list '(0 . "CIRCLE") (cons 10 newPt) (cons 40 newRad) (cons 62 3) (cons 8 "DETAIL") ) ) ) (prompt "\n>>> Run CLIPIT: Select the detail circle and the new (scaled) block.\n" ) (C:CLIPIT) (initget "Single Tangents") (setq lineOption (getkword "\nDraw [Single/Tangents] connector line(s)? <Single>: " ) ) (if (null lineOption) (setq lineOption "Single") ) (if (eq lineOption "Single") (progn (setq vec (mapcar '- newPt cen)) (setq len (distance cen newPt)) (setq dir (mapcar '/ vec (list len len len))) (setq pt1 (mapcar '+ cen (mapcar '* dir (list rad rad rad)))) (setq pt2 (mapcar '- newPt (mapcar '* dir (list newRad newRad newRad)) ) ) (entmakex (list '(0 . "LINE") (cons 10 pt1) (cons 11 pt2) (cons 62 3) (cons 8 "DETAIL") ) ) ) (progn (setq c1 cen r1 rad c2 newPt r2 newRad ) (setq dx (- (car c2) (car c1))) (setq dy (- (cadr c2) (cadr c1))) (setq d (sqrt (+ (* dx dx) (* dy dy)))) (if (<= d (abs (- r1 r2))) (prompt "\nCircles too close — no external tangents.\n") (progn (setq ang3 (atan dy dx)) (setq theta (acos (/ (- r1 r2) d))) (setq ang1 (- ang3 theta)) (setq ang2 (+ ang3 theta)) (setq t1a (polar c1 ang1 r1)) (setq t1b (polar c2 ang1 r2)) (setq t2a (polar c1 ang2 r1)) (setq t2b (polar c2 ang2 r2)) (entmakex (list '(0 . "LINE") (cons 10 t1a) (cons 11 t1b) (cons 62 3) (cons 8 "DETAIL") ) ) (entmakex (list '(0 . "LINE") (cons 10 t2a) (cons 11 t2b) (cons 62 3) (cons 8 "DETAIL") ) ) ) ) ) ) (setq suffix (getstring t "\nEnter detail label suffix (e.g. A): ")) (setq txtHeight (getreal "\nEnter label text height: ")) (setq scaleHeight (* 0.75 txtHeight)) (setq txtStr (strcat "DETAIL-" (strcase suffix))) ;; TEMP TEXT to measure label width (setq txtTemp (entmakex (list '(0 . "TEXT") (cons 8 "DETAIL") (cons 10 '(0 0 0)) (cons 40 txtHeight) (cons 1 txtStr) (cons 7 "Standard") (cons 72 1) (cons 73 0) ) ) ) (setq ext (textbox (entget txtTemp))) (setq txtWidth (abs (- (car (cadr ext)) (car (car ext))))) (entdel txtTemp) (initget "Top Bottom") (setq labelPos (getkword "\nLabel position? [Top/Bottom] <Bottom>: ")) (if (null labelPos) (setq labelPos "Bottom") ) (setq offset (* 1.75 txtHeight)) (cond ((eq labelPos "Top") (setq txtPoint (list (- (car newPt) (/ txtWidth 2.0)) (+ (cadr newPt) newRad offset) 0 ) ) ) ((eq labelPos "Bottom") (setq txtPoint (list (- (car newPt) (/ txtWidth 2.0)) (- (cadr newPt) (+ newRad offset)) 0 ) ) ) ) ;; Place DETAIL label (entmakex (list '(0 . "TEXT") (cons 8 "DETAIL") (cons 10 txtPoint) (cons 40 txtHeight) (cons 1 txtStr) (cons 7 "Standard") (cons 72 0) (cons 73 0) ) ) ;; SCALE TEXT section (correct height and placement) (setq scaleStr (strcat "SCALE: " (rtos scaleFactor 2 2) "X")) (setq scaleTemp (entmakex (list '(0 . "TEXT") (cons 8 "DETAIL") (cons 10 '(0 0 0)) (cons 40 scaleHeight) (cons 1 scaleStr) (cons 7 "Standard") (cons 72 1) (cons 73 0) ) ) ) (setq extScale (textbox (entget scaleTemp))) (setq scaleWidth (abs (- (car (cadr extScale)) (car (car extScale))))) (entdel scaleTemp) (setq scalePoint (list (- (car newPt) (/ scaleWidth 2.0)) (- (cadr txtPoint) (* 1.1 scaleHeight)) 0 ) ) (entmakex (list '(0 . "TEXT") (cons 8 "DETAIL") (cons 10 scalePoint) (cons 40 scaleHeight) (cons 1 scaleStr) (cons 7 "Standard") (cons 72 0) (cons 73 0) ) ) ;; Option to delete the detail circle (initget "Yes No") (setq delCircle (getkword "\nDelete the scaled detail circle? [Yes/No] <No>: " ) ) (if (eq delCircle "Yes") (entdel detailCircle) ) (command "_.LAYER" "_Set" "0" "") (prompt (strcat "\nDetail view created with ClipIt and " txtStr " label created.\n" ) ) (princ) ) Sorry even i am away until 9 july. However thanks for your help . 1 Quote
Recommended Posts
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.