Jump to content

Recommended Posts

Posted

How to get around this problem?

 

I alway set the variable for unused selection sets to nil, but that doesn't seem to solve anything.

 

Is there a definite way to permanently clear selection sets?

 

I don't get it why is there no information avaialable on this topic, when the number of avaialable selection sets is so limited (128 ).

Posted

What situation does it occur in? Setting a selection set variable to nil or the next ss (as the help file says in ssget) always works for me when I'm using selection sets in loops.

Or if it's a vla object you can use vla-delete on the ss.

Posted

I'm using it in a loop, I'm trying to remove self intersections from closed polylines using drawing clean up, thats where I get the error. So the selection set is created by the drawing cleanup routine and I have no control over it.

 

Here is the part of the code which is causing the problem:

 

(setq lof (ssget "_X" (list (cons 0 "LWPOLYLINE") (cons 8 "_lay"))))
(if lof
	(progn
(setq ssn (sslength lof))
(setq i 0)
(repeat ssn
	(setq entx (ssname lof i))
	(command "_change" entx "" "_p" "_la" "tmp" "")
	(command "_-mapclean" "lead.dpf")
	(setq lef (ssget "_X" (list (cons 0 "LWPOLYLINE") (cons 8 "tmp"))))
	(setq sen (sslength lef))
	(setq j 0)
	(repeat sen
		(setq enty (ssname lef j))
		(command "_change" enty "" "_p" "_la" "_lay" "")
		(setq j (1+ j))
	)
	(setq lef nil)
	(gc)
	(setq i (1+ i))
)
))

 

Even adding gc within the loop didn't help.

 

lead.dpf is a saved cleanup routine that runs on the tmp layer.

Posted

What about this instead:

(setq lof (ssget "_X" (list (cons 0 "LWPOLYLINE") (cons 8 "_lay"))))
(if lof
 (progn
   (setq i -1)
   (while (setq entx (ssname lof (setq i (1+ i))))
     ;(command "_change" entx "" "_p" "_la" "tmp" "")
     (entmod (subst (cons 8 "tmp") (assoc 8 (entget entx)) (entget entx)))
     )
   (command "_-mapclean" "lead.dpf")
   (setq i -1)
   (while (setq entx (ssname lof (setq i (1+ i))))
     ;(command "_change" enty "" "_p" "_la" "_lay" "")
     (entmod (subst (cons 8 "_lay") (assoc 8 (entget entx)) (entget entx)))
     )
   )
 )

 

I haven't tested this but I think you might be making a bit of a tangled web with that other code.

Posted

But drawing cleanup breaks the original object to multiple ones, wouldn't this code only set one of the objects back to the original layer?

 

Edit: That gave me an idea, drawing cleanup has the option to create the modified objects on another layer so I don't have to place them back from code. I'll try that and report back.

Posted

That did not work, the error still remains, I've dumped using the drawing clean up command, and using internal functions for cleanup, but the only difference is that I get an access violation error when it runs out of the 128 selection sets.

 

So the question remains how to clear up selection sets without a trace.

Posted

Sorry for not getting back to you (it's morning again now). I don't have that command in autocad so I was just guessing. So it breaks it up into multiple objects. Can you then just make two loops with the command in between?

eg

(setq lof (ssget "_X" (list (cons 0 "LWPOLYLINE") (cons 8 "_lay"))))
(if lof
 (progn
   (setq i -1)
   (while (setq entx (ssname lof (setq i (1+ i))))
     ;(command "_change" entx "" "_p" "_la" "tmp" "")
     (entmod (subst (cons 8 "tmp") (assoc 8 (entget entx)) (entget entx)))
     )
   )
 )
(command "_-mapclean" "lead.dpf")
(setq lof (ssget "_X" (list (cons 0 "LWPOLYLINE") (cons 8 "tmp"))))
(if lof
 (progn
   (setq i -1)
   (while (setq entx (ssname lof (setq i (1+ i))))
     ;(command "_change" entx "" "_p" "_la" "tmp" "")
     (entmod (subst (cons 8 "_lay") (assoc 8 (entget entx)) (entget entx)))
     )
   )
 )

Posted
Sorry for not getting back to you (it's morning again now). I don't have that command in autocad so I was just guessing. So it breaks it up into multiple objects. Can you then just make two loops with the command in between?

eg

 

No because its important, that the cleanup is run on the objects one by one, otherwise it would detect intersections between them and not just self intersections. And the result would be caotic at best.

 

The way I see it there are only two possible solutions. Either break the code after each 100 objects. Or create a routine which could detect and fix self intersections without having to create additional selection sets.

Posted

Hmm, I wish I could step through where it's erring. What if you put the command direct in the loop?

(setq lof (ssget "_X" (list (cons 0 "LWPOLYLINE") (cons 8 "_lay"))))
(if lof
 (progn
   (setq i -1)
   (while (setq entx (ssname lof (setq i (1+ i))))
     ;(command "_change" entx "" "_p" "_la" "tmp" "")
     (entmod (subst (cons 8 "tmp") (assoc 8 (entget entx)) (entget entx)))
     (command "_-mapclean" "lead.dpf")
     )
   )
 )
(setq lof (ssget "_X" (list (cons 0 "LWPOLYLINE") (cons 8 "tmp"))))
(if lof
 (progn
   (setq i -1)
   (while (setq entx (ssname lof (setq i (1+ i))))
     ;(command "_change" entx "" "_p" "_la" "tmp" "")
     (entmod (subst (cons 8 "_lay") (assoc 8 (entget entx)) (entget entx)))
     )
   )
 )

Otherwise you could try this (a slight variation to your original routine)

(setq lof (ssget "_X" (list (cons 0 "LWPOLYLINE") (cons 8 "_lay"))))
(if lof
 (progn
   (setq i -1)
   (while (setq entx (ssname lof (setq i (1+ i))))
     ;(command "_change" entx "" "_p" "_la" "tmp" "")
     (entmod (subst (cons 8 "tmp") (assoc 8 (entget entx)) (entget entx)))
     )
   (command "_-mapclean" "lead.dpf")
   (setq lef (ssget "_X" (list (cons 0 "LWPOLYLINE") (cons 8 "tmp"))))
   (setq j -1)
   (while (setq entx (ssname lef (setq j (1+ j))))
     ;(command "_change" enty "" "_p" "_la" "_lay" "")
     (entmod (subst (cons 8 "_lay") (assoc 8 (entget entx)) (entget entx)))
     )
   )
 )

Otherwise sorry mate I don't know. :( Anyone else have any ideas?

Posted

Thanks for the help, I already gave up trying, I wrote an utility which breaks the objects at self intersections.

 

I'll try ade_ssfree anyway to see if it helps.

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