Jump to content

Recommended Posts

Posted

this one is not working

 

 (foreach e elist
   (entmakex
     (list
   (cons 0 "TEXT")
   (cons 100 "AcDbText")
   (cons 10 (cadr e))
   (cons 40 INALT)
   (cons 1 (rtos (car e) 2 0))
   (if (< (caddr (cadr e)) 0.0)
     (cons 62 4)) 
   (cons 100 "AcDbText")
     ) 
   ) 
) 

 

 

 

 

 

 

and this one is working

 

 

 (foreach e elist
   (entmakex
     (list
   (cons 0 "TEXT")
   (cons 100 "AcDbText")
   (cons 10 (cadr e))
   (cons 40 INALT)
   (cons 1 (rtos (car e) 2 0))
   (cons 100 "AcDbText")
     ) 
   ) 
) 

 

 

 

What's wrong? How can i set color in entmake? something bad with if?

Posted

The code may failed due to the fact that the IF test will return (and append) a nil when the condition isn't meet.

For the second question, the color is stored as integer under DXF code 62; if this code isn't present the color is considered as ByLayer.

Posted

((10 (21.4577 22886.2 20.0) ) (9 (379.39 22984.3 15.4)

) (8 (-61.2626 23323.3 11.8) ) (7

(329.486 23185.6 0.0) ) (6 (279.582 22881.0 0.0)

name: 7e6d9df0>) (5 (252.479 23073.8 0.0) ) (4 (73.0826

23034.2 0.0) ) (3 (113.505 22821.4 0.0)

7e6d9e00>) (2 (169.449 23147.7 -10.0) ) (1 (505.011

23331.8 -24.7) ))

 

This is a sample of elist - for 10 entities

Posted

Did you tried to adjust your code to account for what IF test return?

Posted

I give up to use if inside the entmake, and is ok. Something else: let's say i have a drawing with many points and texts inserted in these points. If i select (highlight) 10 points, how can i select all entities around these 10 points already selected (highlighted), at a distance of ... 5 units ? A lisp already made for such a task?

Posted

So, seems that you managed to solve your issue. Good for you.

 

For that kind of selection, I suppose that you are looking for a kind of "selection circle" centered on said points. Is this correct?

Posted

Yes, is correct, and i want to work this way: first to select few points, then to insert radius value for "selection circle".

Posted

The closest workaround I see is to use a selection polygon (check modes WP and CP of SSGET function). You will then calculate a dozen or two of points equally distanced from said center and then use them to create the desired selection set using one of the above modes.

Posted

Or to use wp or cp for ssget, use a polygon that is a square AxA, where A=Diameter of "selection circle" , then to eliminate from selection set texts with distance to the "center" bigger than radius value?

Any other simpler ideea?

Posted

That solution should work too - please pay attention that this approach will account only for insertion point, not the actual "body" of the text entity.

Posted

I'm still waiting, maybe a simpler ideea will apear... :)

Posted

Until that, you can write code for one of the above solutions and post it here for debug/evaluation, if case. It should, at least, be a good exercise.

Posted

Circular selection - around points - for MSasu - please tell me your opinion - how to improve....etc... :)

 


(defun c:ce (/ ss i en edxf point p1 p2 distsel sel j lst ssf ent lf)
 (setq distsel (getdist "\nDISTANTA SELECTIE :"))
 (princ "\nPUNCTE DE SELECTIE")
 (while (setq ss (ssget "_:S" '((0 . "POINT"))))
   (setq i    0
     en    (ssname ss i)
     edxf    (entget en)
     point    (cdr (assoc 10 edxf))
     p1    (polar point (* 0.25 pi) (* 0.5 distsel))
     p2    (polar point (* 1.25 pi) (* 0.5 distsel))
     sel    (ssget "_C" p2 p1)
     sel    (ssdel en sel)     ; pt indepartarea punctelor din selectie
   )                    
   (repeat (sslength sel)
     (setq en1 (ssname sel i))
     (setq pins (cdr (assoc 10 (entget en1))))
     (if (> (distance pins point) (* 0.5 distsel))
   (ssdel e1 sel)
     ) ;_ end of if
     (setq i (1+ i))
   ) ;_ end of repeat
   (setq lst (cons sel lst))
 ) ;_ end of while
 (setq i 0)
 (repeat (length lst)
   (setq j 0)
   (setq lst2 (nth i lst))
   (repeat (sslength lst2)
     (setq e (ssname lst2 j))
     (setq lf (cons e lf))
     (setq j (1+ j))
   ) ;_ end of repeat
   (setq i (1+ i))
 ) ;_ end of repeat
 (setq ssf (ssadd))
 (foreach ent lf (ssadd ent ssf))
 (sssetfirst nil ssf)
 (princ)
);end defun

Posted

I will check it; at a glance the code seems a little long for what is supposed to do, but I like the messages/comments. Why don't you fill the location field in your profile?

Posted

First, the method is really ineffective; it can be time consuming for many items and, most important, it will miss some items. The later is because the validation method based on DXF code 10 isn't reliable. For example a line can be included or not in selection set based on draw sense, a circle isn't included if center isn't inside selection area, same for text or blocks and so on. Don't forget that your selection mode is Crossing.

 

 

Regarding the code:

  • This line contains an undefined variable:

(ssdel [color=red]e1[/color] sel)

  • You parse the selection set (sel) by an index which take values from 0 to the size of said selection set; but in the same time remove items from selection set. This way may encounter an index that exceed selection set's size, thus error. You must either parse a copy of said selection set or remove the items in a separate parse.

  • The build of cumulated selection set is ineffective; you don't need to construct a list of the found items (list that isn't used later in code, nor returned) and later parse it to add content to selection set - just do this in a single step.

Posted

Another try...

(defun c:ce (/ p r nr point un i lstp ss)
 (setq p (getpoint "\nPUNCT CENTRU :"))
 (setq r (getdist "\nDISTANTA SELECTIE :"))
 ;(setq nr (getint "\nNUMAR PUNCTE PE CERC :"))
 (setq nr 1000)
 (setq un (/ (* 2 pi) nr))
 (setq i 0)
 (repeat nr
   (setq point (polar p (* i un) r))
   (setq lstp (cons point lstp))
   (setq i (1+ i))
 ) ;_ end of repeat
 (setq ss (ssget "_CP" lstp))
 (sssetfirst nil ss)
 (princ)
) ;_ end of defun
 

Posted

That's much better; I took the liberty to optimize a little your code:

(defun c:ce ( / p r nr un lstp )
(if (and (setq p (getpoint "\nPUNCT CENTRU :"))
         (setq r (getdist "\nDISTANTA SELECTIE :")))
 (progn 
  (setq nr 1000
        un 0.0)
  (repeat nr
   (setq lstp (cons (polar p (setq un (+ un (/ (* 2 pi) nr))) r)
                    lstp))
  ) ;_ end of repeat
  (sssetfirst nil (ssget "_CP" lstp))
 )
)
(princ)
) ;_ end of defun

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