Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/11/2025 in all areas

  1. Better armored version, proof against extravagant users ;******************* p o r d e s í a r g o ******************** ;************************ G L A V C V S ************************* ;************************** F E C I T *************************** (defun c:mueveSegmto (/ lstSg dist i se lado op pr pr1 pa pb p1 p2 p3 p4 sgC r aC aR asr dameSgmtos erroria errores error0) (defun erroria () (defun errores (mens) (setq *error* error0) (prin1) ) (setq error0 *error* *error* errores ) ) (defun asr (p1 p2 p3 / a b) (if (> (abs (- (setq a (angle p1 p2)) (setq b (angle p2 p3)))) PI) (if (< a b) (if (> (+ a PI PI) b) - +) (if (> (- a PI PI) b) - +) ) (if (> a b) - +) ) ) (defun dameSgmtos (x pk / f d p s a tam a1 a2 b1 b2 c1 c2 sa sp) (if (= (cdr (assoc 0 x)) "LWPOLYLINE") (progn (setq tam (* (* (getvar "PICKBOX") (/ (getvar "VIEWSIZE") (cadr (setq ss (getvar "SCREENSIZE"))) ) ) 2 ) x (if (= (rem (cdr (assoc 70 x)) 2) 1) (cons (assoc 10 (reverse x)) x) x) b2 (cdr (assoc 10 (cdr (member (cons 10 (setq b1 (cdr (assoc 10 x)))) x)))) c1 (cdr (assoc 10 (cdr (member (cons 10 (setq c2 (cdr (assoc 10 (reverse x))))) (reverse x))))) ) (while (and (setq a1 (cdr p) a2 f f (cdr (assoc (if pk 10 11) (setq x (cdr (member (setq p (assoc 10 x) ) x)))))) (not (setq i (inters f (cdr p) (polar pk (+ (setq a (angle f (cdr p))) 1.5708) tam) (polar pk (- a 1.5708) tam)) )) ) ) (setq sc (list (cdr p) f) f (cdr (assoc (if pk 10 11) (cdr (member (setq p (assoc 10 x)) x)))) sp (if f (list (cdr p) f) (list b1 b2)) sa (if a1 (list a1 a2) (list c1 c2)) ) (list sa sc sp) ) ) ) (erroria) (setq dist (getreal "\nDistance of traslation (ENTER to get the distance on screen): ")) (if (setq lstSg (dameSgmtos (entget (car (setq se (entsel "\nSelect any segment in LWPOLYLINE...")))) (setq pr (cadr se)))) (if (setq pr1 (getpoint (setq pr i) "\nSide to act...")) (if (setq op (asr (setq p2 (car (setq sgC (cadr lstSg)))) pr pr1)) (setq dist (if dist dist (distance pr1 (inters p2 (setq p3 (cadr sgC)) (polar pr1 (- (setq aR (angle p2 p3)) (/ pi 2)) 9999) (polar pr1 (+ aR (/ pi 2)) 9999) nil)) ) pa (polar p2 (setq a (op (angle p2 (setq p3 (cadr sgC))) (/ pi 2.0))) dist) pb (polar p3 a dist) px1 (inters pa pb (car (car lstSg)) p2 nil) px2 (inters pa pb p3 (cadr (last lstSg)) nil) r (entmod (subst (cons 10 px1) (cons 10 p2) (entget (car se)))) r (entmod (subst (cons 10 px2) (cons 10 p3) (entget (car se)))) ) ) ) (princ "\nSelected object is not LWPOLYLINE....Exiting...") ) (princ) )
    4 points
  2. I currently just explode them, PEdit them back to Plines, offset, then extend/trim as needed. The smaller round offs I just use Circle, TTR and guess a good radius, usually between 1-1/2" - 3" or 4" and trim.
    1 point
  3. The small radii are irrelevant (sort of) it's the larger radii that would change, the smaller in between are just rounded off. Examples: Offset at taper 2.dwg
    1 point
  4. Arc segments aren't covered in the code. We don't even know (at least I don't) how they should behave when offsetting.
    1 point
  5. @SLW210 FWIW, The arc sections could be much more complicated than they seem. I guess it depends on the relationships you're trying to maintain - such as tangency. A good way to see this is by adding some tangency parametric constraints, then offsetting an arc segment, then see what happens to the shape when you relocate the vertices. The examples below is not perfect, but you can see how the shape effects all the other arc features.
    1 point
  6. I would use a dcl with toggles so you would check on what you want to run, say Overkill, flatten, purge and so on. Yes you would have a defun for each task. In one task I used to do we had steps like changing layers, load linetypes, change certain blocks to others I am sure you will figure out how to use this .Multi toggles.lsp
    1 point
  7. Just have to insert a line ;;; CADALYST 07/08 www.cadalyst.com/code ;;; Tip 2292: AreaRon.lsp Area of Closed Polylines (c) 2008 Ronald Maneja (Wizman) ;;; PRODUCES TEXT CONTAINING AREA OF SELECTED CLOSED POLYLINES ;;; AND PUTS THEM IN AREARON LAYER ;;; CREATED BY RON MANEJA 31JAN08 ;;; USER INPUTS: SCALE, POLYLINE SELECTION ;;; ;;; VERSION 1.1 (09FEB09): ADDED AREA FOR REGIONS, SPLINE, CIRCLE & ELLIPSE ;;; (defun C:AREARON (/ allx ally areaobj counter ctr el entity-name entnamevla mysset prec_temp pt reg_centroid temp tst vertex x y oldlayer oldsnap temperr traperror blpt cir_center el_center maxpt minpt spl_center trpt ) (defun set_var () (setvar 'cmdecho 0) (setq oldlayer (getvar "clayer")) (setq oldsnap (getvar "osmode")) (setq temperr *error*) (setq *error* traperror) (setvar "osmode" 0) ) (defun traperror (errmsg) (command nil nil nil) (if (not (member errmsg '("console break" "Function Cancelled")) ) (princ (strcat "\nError: " errmsg)) ) (command "_.undo" "end") (setvar "clayer" oldlayer) (setvar "osmode" oldsnap) (setvar "cmdecho" 1) (princ "\nError Resetting Enviroment ") (setq *error* temperr) ) (defun reset_var () (setq *error* temperr) (setvar "clayer" oldlayer) (setvar "osmode" oldsnap) (command "_.undo" "end") (setvar "cmdecho" 1) ) (vl-load-com) (set_var) (command "_.undo" "be") (if (tblsearch "Layer" "AREARON") (command "._layer" "_thaw" "AREARON" "_on" "AREARON" "_unlock" "AREARON" "_set" "AREARON" "") ;_ closes command (command "._layer" "_make" "AREARON" "_color" 1 "AREARON" "") ;_ closes command ) (if (null sch) (setq sch 1.0) ) (initget 6) (setq temp (getreal (strcat "\nENTER SCALE <" (rtos sch 2 2) ">: " ) ) ) (if temp (setq sch temp) (setq temp sch) ) (if (null precision) (setq precision 1) ) (initget 6) (setq prec_temp (getint (strcat "\nHOW MANY DECIMAL PLACES?: <" (rtos precision 2 2) ">: " ) ) ) (if prec_temp (setq precision prec_temp) (setq prec_temp precision) ) (prompt "\nSELECT CLOSED POLYLINES/SPLINES, REGION, CIRCLE & ELLIPSE:> ") (setq mysset (ssget '((-4 . "<or") (-4 . "<and") (0 . "LWPOLYLINE") (70 . 1) (-4 . "and>") (-4 . "<and") (0 . "SPLINE") (70 . 11) (-4 . "and>") (0 . "REGION") (0 . "CIRCLE") (0 . "ELLIPSE") (-4 . "or>") ) ) counter 0 ) (if mysset (progn (while (< counter (sslength mysset)) (setq entity-name (ssname mysset counter) EL (entget entity-name) entnamevla (vlax-ename->vla-object entity-name) areaobj (vla-get-area entnamevla) areaobj (/ areaobj 1000000.) ;;; This line makes mm2 -> m2 ) (cond ((eq (cdr (assoc 0 el)) "LWPOLYLINE") (progn (setq allx 0 ally 0 ctr 0 tst 1 ) (while (assoc 10 el) (setq vertex (cdr (assoc 10 el)) ctr (+ ctr 1) x (car vertex) y (cadr vertex) allx (+ allx x) ally (+ ally y) EL (cdr (member (assoc 10 el) el)) ) ) (setq x (/ allx ctr) y (/ ally ctr) pt (list x y) ) (command "text" "j" "mc" pt (* sch 2.5) "0" (rtos areaobj 2 precision) ) ) ) ((eq (cdr (assoc 0 el)) "REGION") (setq reg_centroid (vlax-safearray->list (vlax-variant-value (vla-get-centroid entnamevla) ) ) ) (command "text" "j" "mc" reg_centroid (* sch 2.5) "0" (rtos areaobj 2 precision) ) ) ((eq (cdr (assoc 0 el)) "CIRCLE") (setq cir_center (vlax-safearray->list (vlax-variant-value (vla-get-center entnamevla) ) ) ) (command "text" "j" "mc" cir_center (* sch 2.5) "0" (rtos areaobj 2 precision) ) ) ((eq (cdr (assoc 0 el)) "ELLIPSE") (setq el_center (vlax-safearray->list (vlax-variant-value (vla-get-center entnamevla) ) ) ) (command "text" "j" "mc" el_center (* sch 2.5) "0" (rtos areaobj 2 precision) ) ) ((eq (cdr (assoc 0 el)) "SPLINE") (vla-GetBoundingBox entnamevla 'minPt 'maxPt) (setq blPt (vlax-safearray->list minPt) trPt (vlax-safearray->list maxPt) ) (setq spl_center (mapcar '* '(0.5 0.5 0.5) (mapcar '+ blPt trPt)) ) (command "text" "j" "mc" spl_center (* sch 2.5) "0" (rtos areaobj 2 precision) ) ) ) (setq counter (+ counter 1)) ) ) (alert "\nNO CLOSED POLYLINES/LWPOLYLINES/SPLINES IN YOUR SELECTION" ) ) (reset_var) (princ) ) (prompt "'\n>>>...AreaRon.Lsp is now Loaded, Type 'Arearon' to start command...<<<") (princ)
    1 point
  8. Thank you @BIGAL for code snippet! I would use that in future .
    1 point
  9. 1 point
×
×
  • Create New...