Jump to content

Stacked Fractions & the FIND Command


GypsyQueen

Recommended Posts

Ok. This is a bug of 2009. Try this lisp.

 

(defun c:sfind(/ cDiv cDem fStr cSet)
 (if
   (and
     (setq cDiv(getint "\nSpecify dividend: "))
     (setq cDem(getint "\nSpecify devider: "))
     (setq fStr(strcat "*"(itoa cDiv) "`#" (itoa cDem)"*"))
     ); end and
   (progn
   (if(ssget "_I")
     (setq cSet(ssget "_I" (list(cons 304  fStr))))
     (setq cSet(ssget "_X" (list(cons 304  fStr))))
     ); end if
   (if cSet
     (progn
       (sssetfirst nil cSet)
(princ(strcat(itoa(sslength cSet)) " found."))
); end progn
     (princ "\nNothing found."))
     ); end if
    ); end progn
   ); end if
   (princ)
 ); end of c:sfind

 

It works with all leaders if nothing selected or with selection only.

Link to comment
Share on other sites

  • Replies 52
  • Created
  • Last Reply

Top Posters In This Topic

  • GypsyQueen

    23

  • soleary

    9

  • lpseifert

    7

  • ASMI

    6

Top Posters In This Topic

Posted Images

Ok. This is a bug of 2009. Try this lisp.

 

Well that definitely found it. Thank you!

 

Now what do I need to do to globally replace all those fractions with a different one? Is that going to have to be a lisp as well? Because just trying to change the contents only winds up opening each individual mtxt box for each leader. Which means if I have 50+ leaders to replace, it's going to be a while.:oops:

Link to comment
Share on other sites

Seems works for replacing:

 

(defun c:sreplace(/ cDiv cDem fStr cSet cStr nStr )
 (if
   (and
     (setq cDiv(getint "\nSpecify dividend: "))
     (setq cDem(getint "\nSpecify devider: "))
     (setq fStr(strcat "*"(itoa cDiv) "`#" (itoa cDem)"*"))
     (setq cStr(strcat (itoa cDiv)"#"(itoa cDem)))
     ); end and
   (progn
   (if(ssget "_I")
     (setq cSet(ssget "_I" (list(cons 304  fStr))))
     (setq cSet(ssget "_X" (list(cons 304  fStr))))
     ); end if
   (if cSet
     (progn
       (sssetfirst nil cSet)
(princ(strcat(itoa(sslength cSet)) " found."))
(if
  (and
    (setq nDiv(getint "\nSpecify new dividend: "))
    (setq nDem(getint "\nSpecify new devider: "))
    ); end and
  (progn
    (foreach txt(mapcar 'vlax-ename->vla-object
	         (vl-remove-if 'listp(mapcar 'cadr(ssnamex cSet))))
      (vla-put-TextString txt
	(vl-string-subst(strcat(itoa nDiv) "#"(itoa nDem))
	  cStr(vla-get-TextString txt)))
     ); end foreach
    ); end progn
  ); end if
); end progn
     (princ "\nNothing found.")
      ); end if
     ); progn
    ); end if
   (princ)
 ); end of c:sreplace

Link to comment
Share on other sites

"; error: no function definition: nil"

 

That pops up at the end after I specify the changes. And of course, no change occurs.

 

I really need to sit down and begin learning lisps. Thank you for your time on this ASMI. :)

Link to comment
Share on other sites

Ha, ha :) It most often error. I fogot to include (vl-load-com) function in my code. It should work:

 

(defun c:sreplace(/ cDiv cDem fStr cSet cStr nStr )
 (vl-load-com)
 (if
   (and
     (setq cDiv(getint "\nSpecify dividend: "))
     (setq cDem(getint "\nSpecify devider: "))
     (setq fStr(strcat "*"(itoa cDiv) "`#" (itoa cDem)"*"))
     (setq cStr(strcat (itoa cDiv)"#"(itoa cDem)))
     ); end and
   (progn
   (if(ssget "_I")
     (setq cSet(ssget "_I" (list(cons 304  fStr))))
     (setq cSet(ssget "_X" (list(cons 304  fStr))))
     ); end if
   (if cSet
     (progn
       (sssetfirst nil cSet)
(princ(strcat(itoa(sslength cSet)) " found."))
(if
  (and
    (setq nDiv(getint "\nSpecify new dividend: "))
    (setq nDem(getint "\nSpecify new devider: "))
    ); end and
  (progn
    (foreach txt(mapcar 'vlax-ename->vla-object
	         (vl-remove-if 'listp(mapcar 'cadr(ssnamex cSet))))
      (vla-put-TextString txt
	(vl-string-subst(strcat(itoa nDiv) "#"(itoa nDem))
	  cStr(vla-get-TextString txt)))
     ); end foreach
    ); end progn
  ); end if
); end progn
     (princ "\nNothing found.")
      ); end if
     ); progn
    ); end if
   (princ)
 ); end of c:sreplace

 

:D

Link to comment
Share on other sites

ASMI.... you're the things that dreams are made of! :D

 

It works perfectly. Thank you so very much!

 

And my co-worker thanks you as well.

Link to comment
Share on other sites

.....And my co-worker thanks you as well.

 

Of course as soon as he tries it out he points out that he doesn't have the option of being able to select objects.

 

He's concerned with the global find & replace replacing some of the fractions he won't want replaced.. Like say he's got several leaders with 2 1/3 and several fractions with 1/3 in them, the lisp will currently replace all version of 1/3 regardless of it being 1/3 alone or 2 1/3.

 

I was tempted to tell him "people in..." well nevermind the euphemism the point is, while he thinks the lisp is awesome, he won't use it because he can't be selective about what it selects. :?

 

ASMI, (or anyone else)if you're still willing to help I'd love to hear your thoughts on it. And I'm beginning to think I should post this in the LISP section of the forums now.

 

Thank you everyone!

 

**tromps off to read the lisp forums and attempt to learn what it is she's looking at**

Link to comment
Share on other sites

It seems long story... Try this:

 

(defun c:sreplace(/ cFul cDiv cDem fStr cSet cStr
	  nStr nFul nDiv nDem)
 (vl-load-com)
 (setq cFul(getint "\nSpecify full part or Spacebar for none: "))
 (if
   (and
     (setq cDiv(getint "\nSpecify dividend: "))
     (setq cDem(getint "\nSpecify devider: "))
     (setq fStr(strcat "*\\A1;" (if cFul(strcat (itoa cFul)" ")"")
		"{\\H0.7x;\\S" (itoa cDiv)
		"`#" (itoa cDem)"*"))
     ); end and
   (progn
   (princ "\n<<< Select leaders to replace text >>>")
   (if(setq cSet(ssget(list(cons 304  fStr))))
     (progn
       (sssetfirst nil cSet)
(princ(strcat(itoa(sslength cSet)) " found."))
(setq nFul(getint "\nSpecify new full part  or Spacebar for none: "))
(if
  (and
    (setq nDiv(getint "\nSpecify new dividend: "))
    (setq nDem(getint "\nSpecify new devider: "))
    ); end and
  (progn
    (foreach txt(mapcar 'vlax-ename->vla-object
	         (vl-remove-if 'listp
		   (mapcar 'cadr(ssnamex cSet))))
      (vla-put-TextString txt
	(vl-string-subst
	  (strcat "\\A1;"(if nFul(strcat(itoa nFul)" ")"")
			  "{\\H0.7x;\\S"(itoa nDiv)
			  "#"(itoa nDem))
	  (vla-get-TextString txt)
	  (vla-get-TextString txt)))
     ); end foreach
    ); end progn
  ); end if
); end progn
     (princ "\nNothing found.")
      ); end if
     ); progn
    ); end if
   (princ)
 ); end of c:sreplace

 

I not can guarantee that it will to work with all your drawings and if improvements you are required can address to me.

Link to comment
Share on other sites

I not can guarantee that it will to work with all your drawings and if improvements are required you can address to me.

 

Thank ASMI! :D I'll give it a try and drop you a message if it doesn't work. I'm out of the department at the moment .

Link to comment
Share on other sites

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