+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Full Member
    Using
    AutoCAD 2009
    Join Date
    Jul 2010
    Posts
    36

    Default real numbers in autolisp

    I have a lisp routine which reads point coordinates from excel sheet and inserts blocks at those points. All the points have 3 decimal places. For example

    614332.785, 2619494.544

    The routine works fine.

    Now in another routine I get the base points of the blocks and compare them to their coordinates in the excel file they are not same but have slight difference for example the base point of the block inserted at above point would be reported by lisp as (614333.0, 261949e+006). What is the reason for this difference. How can I get the same exact value.

    Similarly suppose their is a value 6123.494 stored in an excel cell when I extract that value (using vlisp) the system shows value of variant to be 6123.494 but when I call (valx-variant-value) the returned value becomes 6123 Why this .494 part is omitted. Please guide.

    Thanks

  2. #2
    Forum Deity Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draftsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electrical.
    Using
    AutoCAD 2014
    Join Date
    Oct 2009
    Location
    Great Syria , Lives in Abu Dhabi
    Posts
    3,742

    Default

    Simply change the last number in the function as the following.
    Code:
    (rtos YourNumber 2 3 )
    It is better also to paste your codes to let us check them for you if any other mistakes found...
    Regards

    Tharwat

  3. #3
    Full Member
    Using
    AutoCAD 2009
    Join Date
    Jul 2010
    Posts
    36

    Default

    Thanks Tharwat,

    But I want the end resut as a real number and not string. rtos perhaps converts result to String.

    Any Suggestions?

  4. #4
    Forum Deity Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draftsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electrical.
    Using
    AutoCAD 2014
    Join Date
    Oct 2009
    Location
    Great Syria , Lives in Abu Dhabi
    Posts
    3,742

    Default

    Here it goes;
    Code:
     (setq a 15.12345)
    15.1235
    
    (setq b (rtos a 2 3))
    "15.123"
    
     (setq c (atof b)) 
    15.123
    Regards

    Tharwat

  5. #5
    Luminous Being alanjt's Avatar
    Using
    Civil 3D 2013
    Join Date
    Apr 2008
    Posts
    6,143

    Default

    Registered forum members do not see this ad.

    Read up on EQUAL in the developer's guide.
    DropBox | finding the light...
    Seann: ...it went crazy ex-girlfriend on me...
    eric_monceaux...its pretty funny seeing two AutoCAD Gods give each other flak...

Similar Threads

  1. add numbers
    By hay123 in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 3
    Last Post: 7th Apr 2010, 08:44 am
  2. Help with numbers
    By Nick-H- in forum AutoCAD General
    Replies: 9
    Last Post: 14th Oct 2009, 06:23 pm
  3. Sum Numbers
    By myself in forum AutoCAD General
    Replies: 8
    Last Post: 21st Nov 2008, 08:03 pm
  4. adding numbers to numbers
    By philk in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 23rd Feb 2006, 05:45 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts