Author Topic: Add-Subtract Routine for Architectural/fractions  (Read 8957 times)

0 Members and 1 Guest are viewing this topic.

Biscuits

  • Swamp Rat
  • Posts: 502
Add-Subtract Routine for Architectural/fractions
« on: February 06, 2009, 02:51:44 PM »
Using Acad2008 with Windows XP Pro
I have used a lisp routine that allows me to select an existing number (in text) and increase or decrease the value with a predetermined value automatically.

(2 becomes 3 by just selecting the text etc.)

Does anybody have anything similar that would work with fractions?

(2 15/32  to change to  1 7/32 by subtracting 1 1/4 etc)
Is this a long shot or what?

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Add-Subtract Routine for Architectural/fractions
« Reply #1 on: February 06, 2009, 02:55:44 PM »
Is there anything else in the string?  If not, then it wouldn't be hard, but if so, then it will be a little harder.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Biscuits

  • Swamp Rat
  • Posts: 502
Re: Add-Subtract Routine for Architectural/fractions
« Reply #3 on: February 07, 2009, 01:20:14 PM »
Hello T
Nothing else is in the string.

Hello Cab
TxtInc doesn't seem to like fractions, but it's line of thinking is what I'm looking for.


Thanks guys

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Add-Subtract Routine for Architectural/fractions
« Reply #4 on: February 07, 2009, 08:42:06 PM »
This is not a very well tested version but I'll let you try it.
I started to add real number support some time back as well as fractions but never completed the task.

This is a quick release version that seems to be functioning properly with my limited testing.

<code removed. Too Buggy>
« Last Edit: February 08, 2009, 02:10:01 PM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Add-Subtract Routine for Architectural/fractions
« Reply #5 on: February 09, 2009, 12:01:14 PM »
The simplest way is to use ' distof ' on the string selected ( this will give you a real ), and to use ' getreal ' to get the number to either add or subtract.  Then just do ' rtos ' to the highest precision, and put that back as the string.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Add-Subtract Routine for Architectural/fractions
« Reply #6 on: February 10, 2009, 08:28:51 PM »
Here is another try.
Some testing but needs more.
My goal is to increment the first number within the string while maintaining the format type & precision found in the string.

This are my test strings:
Code: [Select]
  (setq lst      ;  String                          Value Returned   
         (list   
                "abc 10-1      "   ; Invalid Number       nil       
                "abc -10-1     "   ; Invalid Number       nil       
                "abc 3.5       "   ; type:  2             (3.5)     
                "abc 3 1/2     "   ; type:  2 ?5          (3.5)     
                "abc 3 1/2\"    "  ; type:  4             (3.5)     
                "abc 3 1/2'    "   ; type:  4             (42.0)     
                "abc 3-1/2'    "   ; type:  4             (42.0)     
                "abc 3'-1\"     "  ; type:  4             (37.0)     
                "abc 3'-1      "   ; type:  4             (37.0)     
                "abc 3' 1      "   ; type:  4             (37.0)     
                "abc 3' 1\"     "  ; type:  4             (37.0)     
                "abc 3' 1 1/2  "   ; type:  4             (37.5)     
                "abc 3'-1-1/2  "   ; type:  4             (37.5)     
                "abc 3' 1 1/2\" "  ; type:  4             (37.5)     
                "abc 3' 1.5    "   ; type:  4             (37.5)     
                "abc 3'.5     "    ; type   3             (36.5)     
                "abc 3' .5     "   ; type   3             (36.5)     <----<<
                "abc 3'0.5     "   ; type   3             (36.5)     <----<<
                "abc 3'-0.5     "  ; type   3             (36.5)     <----<<
                "abc 3' 0.5     "  ; type   3             (36.5)     <----<<
                "abc -10       "   ; type:  2             (-10.0)   
                "abc .5        "   ; type:  2             (0.5)     
                "abc 0.5       "   ; type:  2             (0.5)     
                "abc 5 -2      "   ; Invalid Number       (5.0 -2.0)
                "abc 1/2       "   ; type:  2 ?5          (0.5)     
                "abc 1/2\"      "  ; type:  4             (0.5)     
                "abc 9 1/2     "   ; type:  2 ?5          (9.5)     
                "abc 1.55E+01  "   ; type:  2             (15.5)     
                "abc 5 A       "   ; type:  6             (5.0)     
                "00000"            ; type:  2             (0.0)     
                "abc"              ;                       nil       
                "abc 3' -1\"     " ; Invalid Number       (36.0 -1.0)
                "abc 3'- 1\"     " ; Invalid Number       (36.0 1.0)
                "abc 3' .5     "   ; Invalid Number       (36.0 0.5)
                "abc 10-1      "   ; Invalid Number       nil       
                "abc -10-1     "   ; Invalid Number       nil       
                "abc 5A        "   ; Invalid Number       (5.0)     
                "This $5.00  is 75 cents short." ;        (5.0 75.0)
                "21'  8-1/5\""     ; too many spaces      (252.0 8.2)
                "15 cde22 35 21 abc 44"  ; (15.0 22.0 35.0 21.0 44.0)
                "abc22abc-10-1-5 def 99"; (22.0 -10.0 -1.0 -5.0 99.0)
         )
 )

<edeit: old code removed>
« Last Edit: February 11, 2009, 04:08:10 PM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Biscuits

  • Swamp Rat
  • Posts: 502
Re: Add-Subtract Routine for Architectural/fractions
« Reply #7 on: February 11, 2009, 02:34:48 PM »
Hey Cab
Thanks for all your hard work!

Routine is working very good
Except the result is in feet & inches

Example:
when adding 1 1/2 to 30 9/16, the  result is 2"-8 1/16".........should be 32 1/16

I looked through the code and I don't see where I need to change this.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Add-Subtract Routine for Architectural/fractions
« Reply #8 on: February 11, 2009, 02:40:40 PM »
Look for an ' rtos ' call.  That is what converts the real to a string.  If no calls to rtos, then let me know if Alan isn't able to help you sooner, and I will look at the code to see if I can find a way.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Biscuits

  • Swamp Rat
  • Posts: 502
Re: Add-Subtract Routine for Architectural/fractions
« Reply #9 on: February 11, 2009, 03:10:16 PM »
Thanks for the response T.

I tried that and found:

 (setq numstr (rtos lastval 2 Prec))

In looking everything over, I'm not clear what to change.
Units are set correctly in my drawing.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Add-Subtract Routine for Architectural/fractions
« Reply #10 on: February 11, 2009, 03:33:06 PM »
It's not a simple fix because the code is not simple.
Looks like the 32 1/16 is an type 5  Fractional Number which I seldom use and didn't test. :)

Let me see what I can do to resolve that.

I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Add-Subtract Routine for Architectural/fractions
« Reply #11 on: February 11, 2009, 04:07:28 PM »
Another attempt :)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Biscuits

  • Swamp Rat
  • Posts: 502
Re: Add-Subtract Routine for Architectural/fractions
« Reply #12 on: February 11, 2009, 04:48:45 PM »
You're not kiddin' the code is not simple! :?


Getting much better.

However in dealing with 32nds it rounds up to nearest 16th

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Add-Subtract Routine for Architectural/fractions
« Reply #13 on: February 11, 2009, 04:53:49 PM »
What is the string to be incremented?
What is the increment amount exactly as entered?
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Biscuits

  • Swamp Rat
  • Posts: 502
Re: Add-Subtract Routine for Architectural/fractions
« Reply #14 on: February 11, 2009, 11:19:35 PM »
29 29/32 (exact string)incremented by 1 1/2 should = 31 13/32 (not 31 7/16)