bababarghi Posted March 12, 2014 Posted March 12, 2014 (edited) Hi all, I am trying to write a code to select all of RevClouds in my drawing. I found this one to start with: (defun c:SelectAllRevClouds (/ ss) (if (setq ss (ssget "x" '((0 . "LWPOLYLINE") (410 . "Model") (70 . 1) (-4 . "/=") (42 . 0) (-4 . ">") (90 . 4) ) ) ) ) It partially works but not exactly what I want. Some RevClouds are skipped. Any idea how I can select all of my RevClouds ? Edited March 16, 2014 by bababarghi Editing title Quote
Snownut Posted March 12, 2014 Posted March 12, 2014 That would be rather difficult with out a drawing to look at. Try making some adjustments to this; (ssget "x" '((0 . "LWPOLYLINE") (410 . "Model") (70 . 1) (-4 . "/=") (42 . 0) (-4 . ">") (90 . 4) ) Quote
bababarghi Posted March 12, 2014 Author Posted March 12, 2014 The sample drawing is attached. Issue: Forgetting about RevClouds in Layouts, some RevClouds in Model are also getting ignored by the code. Sample DRG.dwg Quote
Snownut Posted March 12, 2014 Posted March 12, 2014 Looking at the DXF codes; (70 . 1) = the LWPOLYLINE is closed, you have two rev clouds that are not closed. (if you don't care if the rev-clouds are closed eliminate this criteria, beware you may collect other entities) (410 . "Model") = only entities in "MODEL" space are collected see link here for all DXF codes for different entities. http://exchange.autodesk.com/autocad/enu/online-help/browse#WS1a9193826455f5ff18cb41610ec0a2e719-79fc.htm Quote
bababarghi Posted March 13, 2014 Author Posted March 13, 2014 Thanks Snownut. That was a great help. So, here is what I 'm up to now: (Sorry gurus. My code may look extremely inefficient and preliminary to you ) (defun FixAllRevClouds (/ ss ss1) ;importing CLOUD layer into drawing (command "._-insert" "Q:\\..............\\Cloud Layer.dwg" "0.0,0.0" "" "" "") ; deleting imported junk (command "._Erase" "l" "") ;============================== ;Selecting all RevClouds (setq ss (ssget "x" '((0 . "LWPOLYLINE") (-4 . "/=") (42 . 0) (-4 . ">") (90 . 4) ) ) ) (if (/= nil ss) (command "_.chprop" ss "" "LA" "CLOUD" "") ) ;============================== ;Selecting all Revision Triangles (setq ss1 (ssget "x" '((0 . "INSERT") (2 . "rev-Tri") ) ) ) (if (/= nil ss1) (command "_.chprop" ss1 "" "LA" "CLOUD" "") ;Note to Layer name should exactly match ) ) (defun c:RunFixAllRevClouds(/ var1) (setq var1 (getvar "TILEMODE")) (setvar "TILEMODE" 1) (FixAllRevClouds) (setvar "TILEMODE" 0) (FixAllRevClouds) (setvar "TILEMODE" var1) ) (c:RunFixAllRevClouds) BUGS 1- There should always exist a revcloud in each space 2- Rectangles with filleted corners are considered as Revclouds The main idea was to select all RevClouds and rev-Tri blocks and put them on CLOUD layer. Quote
Snownut Posted March 13, 2014 Posted March 13, 2014 Possible issues, the first selection set will collect all lwpolylines with at least 5 vertices and bulge = verticies, many lwpolylines meet that criteria, that's why the closed lwpolyline requirement was there. Quote
bababarghi Posted March 13, 2014 Author Posted March 13, 2014 OK. But even with compromising open RevClouds and adding (70 . 1) back to SSGET, rectangles with filleted corners still getting selected. Am I correctly following your previous post? Quote
Tharwat Posted March 13, 2014 Posted March 13, 2014 This may work . (defun c:test (/ s e i a p) ;; Tharwat 13.03.2014 ;; (if (setq s (ssget "_X" '((0 . "LWPOLYLINE") (410 . "Model") (-4 . "/=") (42 . 0) (-4 . ">") (90 . 4)))) (repeat (setq i (sslength s)) (setq e (ssname s (setq i (1- i))) a (length (vl-remove-if-not '(lambda (u) (and (eq (car u) 42) (not (eq (cdr u) 0)))) (entget e))) p (length (vl-remove-if-not '(lambda (u) (eq (car u) 10)) (entget e))) ) (if (not (or (eq a p) (eq (1+ a) p))) (ssdel e s) ) ) ) (sssetfirst nil s) (princ) ) Quote
bababarghi Posted March 14, 2014 Author Posted March 14, 2014 This may work. Thanks Tharwat. That definitely does. I wonder how I can tweak your code to select RevClouds in paper space as well. As I mentioned in my previous post, I need to push all RevClouds to a different layer. Quote
Tharwat Posted March 14, 2014 Posted March 14, 2014 Thanks Tharwat. That definitely does. Excellent , happy to hear that . I wonder how I can tweak your code to select RevClouds in paper space as well. As I mentioned in my previous post, I need to push all RevClouds to a different layer. That would be easy , as yo have mentioned in your last reply that you got it working , if not just ask and would be happy to help . Good luck . Quote
pBe Posted March 14, 2014 Posted March 14, 2014 (defun c:test (/ s e i a p) (if ;; ElpanovEvgeniy ;; (setq s (ssget "_X" '((0 . "LWPOLYLINE") (-4 . "/=") (42 . 0) (-4 . ">") (90 . 4) ) ) ) (repeat (setq i (sslength s)) (setq e (ssname s (setq i (1- i)))) ;;; pBe13March2014 ;;; (if (not (vl-some '(lambda (x) (if (and (= (car x) 42) (= (cdr x) 0) ) x ) ) (setq ent (entget e))) ) (entmod (subst '(8 . "RevClouds") (assoc 8 ent) ent)) ) ) )(princ) ) Quote
Tharwat Posted March 14, 2014 Posted March 14, 2014 pBe Sorry to say that does not work on opened Revclouds . Quote
pBe Posted March 14, 2014 Posted March 14, 2014 pBe Sorry to say that does not work on opened Revclouds . Wasn't aware there's such a thing as opened Revclouds my friend. but good point nonetheless. I'll stick with code i posted for now as i don't see a need to include those items in question. 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.