Jump to content

Recommended Posts

Posted (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 by bababarghi
Editing title
Posted

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)  
             )

Posted

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

Posted

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

Posted

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 :oops: )

 

(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.

Posted

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.

Posted

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?

Posted

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)
)

Posted
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.

Posted

Thanks everyone. Job done. :)

Posted
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 .

Posted
(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)
)

Posted
pBe Sorry to say that does not work on opened Revclouds .

 

:lol: 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.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...