Jump to content

Leaderboard

Popular Content

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

  1. @Steven P just a tip, this: (strcat "") ; versine under 7 Can be simply: "" ; versine under 7
    1 point
  2. And with your code modified simply... (defun c:UCS_Pick_Object_BuiltInCmd (/ *error* acDoc var_cmdecho vsize) (vl-load-com) (defun *error* (errmsg) (and acDoc (vla-EndUndoMark acDoc)) (and errmsg (not (wcmatch (strcase errmsg) "*CANCEL*,*EXIT*")) (princ (strcat "\n<< Error: " errmsg " >>\n")) ) (setvar 'cmdecho var_cmdecho) ) (setq acDoc (vla-get-ActiveDocument (vlax-get-acad-object))) (or (vla-EndUndoMark acDoc) (vla-StartUndoMark acDoc)) (setq var_cmdecho (getvar 'cmdecho)) (setq vsize (getvar 'viewsize)) (setvar 'cmdecho 0) (progn (command "_.ucs" "_Object" pause "_plan" "") (command "_.zoom" "_Ce" (trans (getvar 'ucsorg) 0 1) vsize) (princ "UCS now set to the line, objects polyline segment or objects UCS") ) (vla-EndUndoMark acDoc) (*error* nil) (princ) )
    1 point
  3. 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) )
    1 point
  4. Thanks, @marko_ribar and @Steven P. I like how the built-in UCS command handles a picked object. Depending on which side of a polyline or line segment you pick determines the orientation of the new UCS. So I came up with the idea of retrieving the previous window coordinates before the UCS command was issued. With help from a fn from Lee Mac of course. This gets it close enough to where I need to be after running the UCS command and not send me into outer space after running the plan command. GIF and code: ;; ;; Restores the zoomed in window after running the command "UCS" "_OB" followed by the plan command ;; Written on 2023.07.18 by 3dwannab ;; LM:ViewportExtents by Lee Mac (THANKS AGAIN) ;; (defun c:I_LIKE_TO_ZOOM_IT_ZOOM_IT (/ *error* acDoc LM:ViewportExtents pt1 pt2 vp_pts) (vl-load-com) ;; Viewport Extents - Lee Mac ;; Returns two WCS points describing the lower-left and ;; upper-right corners of the active viewport. (defun LM:ViewportExtents (/ c h v) (setq c (trans (getvar 'viewctr) 1 0) h (/ (getvar 'viewsize) 2.0) v (list (* h (apply '/ (getvar 'screensize))) h) ) (list (mapcar '- c v) (mapcar '+ c v)) ) (defun *error* (errmsg) (and acDoc (vla-EndUndoMark acDoc)) (and errmsg (not (wcmatch (strcase errmsg) "*CANCEL*,*EXIT*")) (princ (strcat "\n<< Error: " errmsg " >>\n")) ) ) (setq acDoc (vla-get-ActiveDocument (vlax-get-acad-object))) (or (vla-EndUndoMark acDoc) (vla-StartUndoMark acDoc)) (setq vp_pts (LM:ViewportExtents)) (command "ucs" "_OB" pause "plan" "") (setq pt1 (vlax-3d-point (car vp_pts))) (setq pt2 (vlax-3d-point (cadr vp_pts))) ; Restores the portion of the screen you were originally in (vla-ZoomWindow acadObj pt1 pt2) (vla-EndUndoMark acDoc) (*error* nil) (princ) ) (c:I_LIKE_TO_ZOOM_IT_ZOOM_IT)
    1 point
×
×
  • Create New...