Jump to content

Recommended Posts

Posted

Say impossible is not true . Who can do , solve it , Wonder full.

Thanks ROY_043

  • Replies 35
  • Created
  • Last Reply

Top Posters In This Topic

  • Raje

    14

  • devitg

    6

  • ronjonp

    5

  • Roy_043

    5

Top Posters In This Topic

Posted
Right. Plus there is a bigger problem with my code in post #17: non-integer texts should be filtered out as well. :oops:

 

 

very happy with your code.:):) sample file works well. and some times getting not found error. please test with my file.

 

thank you very much...:):)

Test File.dwg

Posted
Not winning any speed tests :), but here's another one:

working good, but takes time while executing on more texts. its ok..

thank you for your participation.

Posted

@ronjonp:

Using the IntersectWith method is a good idea. It is more accurate than my bounding box approach for rotated texts.

 

@Grrr:

For rectangular polylines the function may indeed be useful. But not for more complex polylines.

 

@Raje:

I am not getting a 'not found error' with that last dwg. But I do notice that the line portion of underlined texts is not taken into account for the bounding box. Note: I use BricsCAD.

Posted

@ronjonp:

Isn't this code risky when s is not an "_X" selection set?:

(vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))

In some cases the return value can contain the same ename multiple times.

Posted
@ronjonp:

Isn't this code risky when s is not an "_X" selection set?:

(vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))

In some cases the return value can contain the same ename multiple times.

 

I've never seen this behavior?

Posted
I've never seen this behavior?
Must be something wrong with my memory. Disregard my previous post.
Posted
very happy with your code.:):) sample file works well. and some times getting not found error. please test with my file.

 

thank you very much...:):)

 

So many times code is written to clean up messes. How was this mess created in the first place?

Posted
Must be something wrong with my memory. Disregard my previous post.

 

No worries. Happens to the best of us :)

Posted

Thank Roy..with help of your code saving my time.

Posted
Thank you, ronjonp..

 

Glad to help. If you have very large drawings, it may help speed to select portions rather than doing all at once. I updated my code a bit to hopefully improve sped a little bit.

  • 1 year later...
Posted
On 10/30/2017 at 10:56 PM, ronjonp said:

Not winning any speed tests :), but here's another one:

 


(defun c:foo (/ a l s s2 tmp)
 (defun _foo (str / i tmp)
   (setq i (vl-string->list ".0123456789"))
   (if	(setq tmp (vl-remove-if-not '(lambda (x) (vl-position x i)) (vl-string->list str)))
     (atof (apply 'strcat (mapcar 'chr tmp)))
   )
 )
 (if (setq s (ssget ":L" '((0 . "text"))))
   (progn
     (foreach x (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))))
(if (setq tmp (_foo (vla-get-textstring x)))
  (setq s2 (cons (cons tmp x) s2))
)
     )
     (setq s (vl-sort s2 (function (lambda (a b) (> (car a) (car b))))))
     (while (setq a (car s))
(if (setq
      l	(vl-remove-if-not
	  (function (lambda (x) (vlax-invoke (cdr a) 'intersectwith (cdr x) acextendnone)))
	  (setq s (cdr s))
	)
    )
  (progn (while	(setq tmp
		       (vl-some
			 (function
			   (lambda (x)
			     (vl-remove-if-not
			       (function
				 (lambda (y) (vlax-invoke (cdr y) 'intersectwith (cdr x) acextendnone))
			       )
			       (vl-remove-if (function (lambda (z) (vl-position z l))) s)
			     )
			   )
			 )
			 l
		       )
		)
	   (setq l (cons (car tmp) l))
	 )
	 (mapcar (function (lambda (x) (setq s (vl-remove x s)) (vla-delete (cdr x)))) l)
	 (vla-put-color (cdr a) 1)
	 (vla-update (cdr a))
  )
)
     )
   )
 )
 (princ)
)
(vl-load-com)
What if the texts are not overlapping, but within a small distances. Example to get the max from the set of 3 or 4 texts selected and so if there are many such locations can the command be repeated with a while t.

 

 

Posted
On 10/30/2017 at 4:37 AM, BIGAL said:

Try this no checking for text matching or smarter handling of numbers.

 

 


(defun c:max-min ( / ss mylist obj biggest smallest inspt)
(alert "Press <Cr> to exit loop")
(while (setq ss (ssget (list (cons 0 "Text"))))
(setq mylist '())
(repeat (setq x (sslength ss))
(setq obj (vlax-ename->vla-object (ssname ss (setq x (- x 1)))))
(setq mylist (cons (vla-get-textstring obj) mylist))
(setq inspt (vlax-safearray->list (vlax-variant-value (vla-get-insertionpoint obj))))
)
(setq biggest (rtos (apply 'max (mapcar 'atof mylist))2 3))
(setq smallest (rtos (apply 'min (mapcar 'atof mylist))2 3))
;(alert (strcat "The biggest is ... " biggest "\n\nThe smallest is ... " smallest))
(command "Text"(getpoint "pick text point") "" "" biggest)
)
)
Dear Bigal, can you post your original code with erase; and also can it take multiple sets with a given distances between the texts  and placing the max at its original location with zero degree text rotation.

 

 

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