Leaderboard
Popular Content
Showing content with the highest reputation on 08/04/2023 in all areas
-
This can help you? (vl-load-com) (defun c:Dim_PolyArc ( / js AcDoc modelSpace n ename obj pr dist_start dist_end pt_start pt_end pt_sel seg_len seg_bulge pos offset ang_base ang rad alpha pt_cen) (princ "\nSelect polylines.") (while (null (setq js (ssget '((0 . "LWPOLYLINE"))))) (princ "\nSelection is empty, or aren't POLYLINES!") ) (setq AcDoc (vla-get-ActiveDocument (vlax-get-acad-object)) modelSpace (vla-get-ModelSpace Acdoc) ) (vla-StartUndoMark AcDoc) (repeat (setq n (sslength js)) (setq ename (ssname js (setq n (1- n))) obj (vlax-ename->vla-object ename) pr -1 ) (repeat (fix (vlax-curve-getEndParam obj)) (setq dist_start (vlax-curve-GetDistAtParam obj (setq pr (1+ pr))) dist_end (vlax-curve-GetDistAtParam obj (1+ pr)) pt_start (vlax-curve-GetPointAtParam obj pr) pt_sel (vlax-curve-GetPointAtParam obj (+ pr 0.5)) pt_end (vlax-curve-GetPointAtParam obj (1+ pr)) seg_len (- dist_end dist_start) seg_bulge (vla-GetBulge obj pr) ang_base (angle pt_start pt_end) ) (if (or (not offset) (and (not (eq (getvar "USERR1") (* pi 0.5))) (not (eq (getvar "USERR1") (* pi 1.5))))) (progn (initget 1) (setq pos (getpoint pt_sel "\nPosition for all dimensions: ") offset (distance pt_sel pos) ang (angle pt_sel pos) ) (setvar "USERR1" (if (eq (rem pi (- ang ang_base)) pi) (* 0.5 pi) (* 1.5 pi))) ) ) (if (not (zerop seg_bulge)) (progn (setq rad (/ seg_len (* 4.0 (atan seg_bulge))) alpha (+ (angle pt_start pt_end) (- (* pi 0.5) (* 2.0 (atan seg_bulge)))) pt_cen (polar pt_start alpha rad) ) (vlax-put (vla-AddDimAngular modelSpace (vlax-3d-point pt_cen) (vlax-3d-point pt_start) (vlax-3d-point pt_end) (vlax-3d-point (polar pt_sel (+ ang_base (getvar "USERR1")) offset)) ) 'TextOverride (vl-string-subst (getvar "DIMDSEP") "." (rtos seg_len (getvar "DIMLUNIT") (getvar "DIMDEC"))) ) ) (vla-AddDimAligned modelSpace (vlax-3d-point pt_start) (vlax-3d-point pt_end) (vlax-3d-point (polar pt_sel (+ ang_base (getvar "USERR1")) offset)) ) ) ) ) (vla-EndUndoMark AcDoc) (prin1) )3 points
-
So close just need to add an if statement. Also sorted your list by color number -Edit Added undo points Fyi (foreach ent (mapcar 'cadr (ssnamex ss))) ;ssget "_X" (foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))) ;all other ssget (foreach obj (mapcar 'vlax-Ename->Vla-Object (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))) ;if you want vla-objects instead of ename (defun c:PipeConvert_IRRI_UPDATE (/ Datalist ss f i ent eData) (vl-load-com) (vla-startundomark (setq doc (vla-get-activedocument (vlax-get-acad-object)))) ;list (Color | Layer | Global Width) (setq Datalist '((1 "P_DN90-6" 0.2) (2 "P_DN250-6" 0.3) (3 "P_DN110-6" 0.25) (4 "P_DN63-6" 0.15) (5 "P_DN160-6" 0.3) (6 "P_DN50-6" 0.15) (7 "P_DN315-6" 0.3) (8 "P_DN140-6" 0.2) (9 "P_DN315-8" 0.3) (14 "P_DN90-10" 0.2) (20 "P_DN225-6" 0.3) (21 "P_DN32-4" 0.1) (22 "P_DN32-6" 0.1) (24 "P_DN16-4" 0.05) (26 "P_DN32-8" 0.1) (51 "P_DN25-6" 0.05) (52 "P_DN450-6" 0.3) (54 "P_DN25-4" 0.05) (56 "P_DN250-12.5" 0.3) (58 "P_DN63-10" 0.15) (81 "P_DN110-10" 0.25) (82 "P_DN280-6" 0.3) (86 "P_DN280-10" 0.3) (91 "P_DN110-12.5" 0.25) (92 "P_DN280-8" 0.3) (94 "P_DN40-6" 0.1) (96 "P_DN280-12.5" 0.3) (111 "P_DN140-10" 0.2) (112 "P_DN355-6" 0.3) (116 "P_DN40-8" 0.1) (120 "P_DN63-8" 0.15) (121 "P_DN140-8" 0.2) (122 "P_DN40-4" 0.1) (134 "P_DN110-8" 0.25) (171 "P_DN160-10" 0.3) (172 "P_DN160-8" 0.3) (174 "P_DN20-4" 0.05) (176 "P_DN160-12.5" 0.3) (178 "P_DN75-12.5" 0.15) (200 "P_DN225-8" 0.3) (201 "P_DN225-10" 0.3) (202 "P_DN75-6" 0.15) (204 "P_DN225-12.5" 0.3) (206 "P_DN75-10" 0.15) (208 "P_DN75-8" 0.15) (214 "P_DN50-10" 0.15) (230 "P_DN50-8" 0.15) (231 "P_DN200-6" 0.3) (234 "P_DN16-6" 0.05) (238 "P_DN90-8" 0.2) (252 "P_DN315-12.5" 0.3) (253 "P_DN315-10" 0.3) (254 "P_DN125-6" 0.2))) (if (setq ss (ssget "_X" '((0 . "LINE") (8 . "MAINLINE_PIPES,ZONE_PIPES,SPRAYLINES")))) (foreach ent (mapcar 'cadr (ssnamex SS)) (setq eData (mapcar '(lambda (d) (cdr (assoc d (entget ent)))) '(62 10 11))) (if (setq f (assoc (car edata) Datalist)) ;if f # isnt found skip entity (progn (ssdel ent ss) (entmake (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(90 . 2) '(70 . 0) (cons 8 (cadr f)) (cons 43 (caddr f)) (cons 10 (cadr eData)) (cons 10 (caddr eData)) ) ) ) ) ) ) (vla-endundomark doc) (princ) )2 points
-
Hi. following this topic, I have a list ("Datalist" in the attached lisp) that contain a color and layer definition. the ssget list contain lines from 3 designated layer in the drawing,and each line has a color (obviously...). I need to take out all the lines from the ssget list that their color is not in the Datalist, and use that list in the foreach loop. is there a way to do it? I've attached a sample drawing that contain the lines to convert and the lisp. one line has a color number of 23 that is not in the Datalist. I need to take it out of the list that go to the foreach loop. Any help will be appreciated!! thanks, aridzv. PipeConvert_IRRI_UPDATE.lsp sample.dwg1 point
-
You didn't copy my complete code. Looking at your other post you need this in the start for it not to error. (defun c:PipeConvert_IRRI_UPDATE (/ Datalist ss f i ent eData) (vl-load-com) (vla-startundomark (setq doc (vla-get-activedocument (vlax-get-acad-object)))) Its always good practice to add undo marks if your doing a lot of different operations to a drawing. Say your ssget gets over 1000 lines it processes 723 of those 1000. that would take 1446 undo's one for each entity drawn and one for each line deleted. to return the drawing back to they way it was before the command was executed. You would basically have to hold Crtrl + Z for like 2-3 mins. Or just have the startundomark and endundomark and undo everything in one second. (if you wanted to) more here1 point
-
Correct, it works fine in the supplied drawing with the fields converted to text.1 point
-
No problem, I'd seen MHupps answer - usually a good solution - and thought he'd fix a few things in it too but didn't get chance to look at it working yet.1 point
-
@Steven P Hi. see in this topic - @mhupp helped me with the error handeling if a line color dosn't excist in the list, and changed the code a bit, using only CONS10, change that allowed me to make this change to include polylines: the original code - only for LINE: (if (setq ss (ssget "_X" '((0 . "LINE") (8 . "MAINLINE_PIPES,ZONE_PIPES,SPRAYLINES")))) changed to this to include polylines as well: (if (setq ss (ssget "_X" '((0 . "LINE,LWPOLYLINE") (8 . "MAINLINE_PIPES,ZONE_PIPES,SPRAYLINES")))) here is the final code that I'm using: (defun c:PipeConvert_IRRI_UPDATE (/ Datalist ss f i ent eData) (setq Datalist ; Color | Layer | Global Width '((174 "P_DN20-4" 0.05) (24 "P_DN16-4" 0.05) (234 "P_DN16-6" 0.05) (54 "P_DN25-4" 0.05) (51 "P_DN25-6" 0.05) (21 "P_DN32-4" 0.1) (22 "P_DN32-6" 0.1) (26 "P_DN32-8" 0.1) (122 "P_DN40-4" 0.1) (94 "P_DN40-6" 0.1) (116 "P_DN40-8" 0.1) (6 "P_DN50-6" 0.15) (230 "P_DN50-8" 0.15) (214 "P_DN50-10" 0.15) (4 "P_DN63-6" 0.15) (120 "P_DN63-8" 0.15) (58 "P_DN63-10" 0.15) (202 "P_DN75-6" 0.15) (208 "P_DN75-8" 0.15) (206 "P_DN75-10" 0.15) (178 "P_DN75-12.5" 0.15) (1 "P_DN90-6" 0.2) (238 "P_DN90-8" 0.2) (14 "P_DN90-10" 0.2) (3 "P_DN110-6" 0.25) (134 "P_DN110-8" 0.25) (81 "P_DN110-10" 0.25) (91 "P_DN110-12.5" 0.25) (254 "P_DN125-6" 0.2) (8 "P_DN140-6" 0.2) (121 "P_DN140-8" 0.2) (111 "P_DN140-10" 0.2) (5 "P_DN160-6" 0.3) (172 "P_DN160-8" 0.3) (171 "P_DN160-10" 0.3) (176 "P_DN160-12.5" 0.3) (231 "P_DN200-6" 0.3) (20 "P_DN225-6" 0.3) (200 "P_DN225-8" 0.3) (201 "P_DN225-10" 0.3) (204 "P_DN225-12.5" 0.3) (2 "P_DN250-6" 0.3) (56 "P_DN250-12.5" 0.3) (82 "P_DN280-6" 0.3) (92 "P_DN280-8" 0.3) (86 "P_DN280-10" 0.3) (96 "P_DN280-12.5" 0.3) (7 "P_DN315-6" 0.3) (9 "P_DN315-8" 0.3) (253 "P_DN315-10" 0.3) (252 "P_DN315-12.5" 0.3) (112 "P_DN355-6" 0.3) (52 "P_DN450-6" 0.3) ) ) (setvar 'CECOLOR "BYLAYER") (if (setq ss (ssget "_X" '((0 . "LINE,LWPOLYLINE") (8 . "MAINLINE_PIPES,ZONE_PIPES,SPRAYLINES")))) (foreach ent (mapcar 'cadr (ssnamex SS)) (setq eData (mapcar '(lambda (d) (cdr (assoc d (entget ent)))) '(62 10 11))) (if (setq f (assoc (car edata) Datalist)) ;if f # isnt found skip entity (progn (ssdel ent ss) (entmake (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(90 . 2) '(70 . 0) (cons 8 (cadr f)) (cons 43 (caddr f)) (cons 10 (cadr eData)) (cons 10 (caddr eData)) ) ) ) ) ) ) ;;(vla-endundomark doc) (princ) ) thanks for your help - it gave me lids on how to get it right!!! aridzv.1 point
-
@ASQ, Maybe it can be done by ODBX, please upload at least 3 samples.dwg1 point