Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: Need Lisp For Feets to Meters with 2 decimals only

  1. #11
    Certifiable AUGI Addict
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: Need Lisp For Feets to Meters with 2 decimals only

    What exactly are you after?

    Do you want to convert the entire drawing from ft to m? That's just a scale operation - or more properly set the units correctly in the source file (i.e. use the units command), insert it as a block in the target (once you've got the target set to the correct units using the units command) and it would scale correctly (no Lisp needed). The Units command opens a dialog in which you adjust the various settings, the same settings as you can change on the command-line through the dwgunits command. BTW, read what it says on the command-line when you use the dwgunits command, it explains exactly what each setting is meant for.

    However, such conversions are done at as much precision as acad can muster. If you want to "see" only 2 digits of the meter, then change your default unit display (again in that units command) and/or adjust your dimension style to suit (in the dimstyle command).

    Regarding how to run Lisp ... just start typing it in the command line. When you start with a (, the rest are interpreted as lisp program code. Otherwise save it in a text file (suggest changing the extension to LSP instead of TXT), then use the AppLoad command, or type the following at the command line:
    Code:
    (load "full path to the text file you saved")
    That simply loads the text as if you typed it into the command line.

    Do you actually want to convert the line length to throw away the extra digits? This is going to cause lots of inaccuracies, lines not touching each other, and actual lengths not working out in totals. I'd advise you don't go this route - it's a lot of extra work and you get very bad results (especially if your drawing has lines at angles other than along an axis). E.g. 1 ft is in fact 0.3048m, you want it to become 0.30m instead (as that is a rounded value). But 2 ft is 0.6096m, rounded that becomes 0.61 (which is not 2x0.30) - what would you like to do in this case?

    To fake it, you could scale by a factor of 0.3 instead of the correct factor of 0.3048. But then note that you're actually not converting properly - you introduce a length error which gets proportionately worse. Over 200 ft you'd be out by an entire meter. I.e. at 60m you'd be 1m short of the actual measurement (i.e. just under a 2% error).

  2. #12
    Member
    Join Date
    2016-01
    Posts
    46
    Login to Give a bone
    0

    Default Re: Need Lisp For Feets to Meters with 2 decimals only

    Quote Originally Posted by tedg View Post
    So you're a student... studying what exactly?
    Is this for an assignment or part of a project?

    If so, do they not teach how to use lisp in this course?
    Dear sir,

    i have basic idea about lisps and know about how to run.it is for project work execution.

    Thank you sir,
    Best regards.

  3. #13
    Member
    Join Date
    2016-01
    Posts
    46
    Login to Give a bone
    0

    Default Re: Need Lisp For Feets to Meters with 2 decimals only

    Dear Experts,

    Kindly provide programmable code..

    Thanks in Advance.

  4. #14
    Member
    Join Date
    2016-09
    Posts
    2
    Login to Give a bone
    0

    Default Re: Need Lisp For Feets to Meters with 2 decimals only

    HI I am trying to change existing drawing properties values in AUTOCAD with pop list below and just cant get there. Is there anyone who could help edit the code.


    lisp

    Code:
    (defun c:building ( / *error* UpdateList data dclfile dclhandle )
    
      ;; Accompanying DCL File:
    
      (setq dclFile "building.dcl")
    
      (defun *error* ( msg )
    
        ;; Error Handler - will unload the dialog
        ;; from memory should the user decide to hit Esc
    
        (if dclHandle (unload_dialog dclHandle))
        (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
            (princ (strcat "\n** Error: " msg " **")))
        (princ)
      )
    
      (defun UpdateList ( key lst )
    
        ;; This function updates the list_box associated with the specified key
        ;; using the contents of the supplied lst
    
        (start_list key)
        (mapcar 'add_list lst)
        (end_list)
      )
    
      ;; Data used to Populate List_Boxes:
      ;; I've chosen to use this list structure because it suits the data,
      ;; but there are many other possibilities.
    
      (setq Data
       '(   
    ("Tillson Nbr. 1	 -	383	"	("	120 Tillson,	Amherst,	MA"))
    ("Tillson Nbr. 2	 -	384	"	("	121 Tillson,	Amherst,	MA"))
    ("Tillson Nbr. 3	 -	385	"	("	122 Tillson,	Amherst,	MA"))
    ("Tillson Nbr. 4	 -	157	"	("	123 Tillson,	Amherst,	MA"))
    ("Tillson Nbr. 5	 -	158	"	("	124 Tillson,	Amherst,	MA"))
    ("Tillson Nbr. 6	 -	160	"	("	135 Tillson,	Amherst,	MA"))
           
        )
      )
    
      ;; Start of Main Routine
      ;; Lots of Error Trapping to make sure the Dialog Loads:
    
      (cond
        ( (<= (setq dclHandle (load_dialog dclFile)) 0)
    
          (princ "\n--> DCL File not Found.")
        )
        ( (not (new_dialog "building" dclHandle))
    
          (setq dclHandle (unload_dialog dclHandle))
          (princ "\n--> Dialog Definition not Found.")
        )
        ( t
          ;; Dialog Loaded Successfully.
    
          (or *Name*  (setq *Name*  "0"))
          (or *Address* (setq *Address* "0"))
    
          ;; Set up some default selections, for the first-time running of the program.
          ;; The variables *Name* & *Address* are intended to be global and hence will
          ;; remember the user's last selections.
    
          ;; Populate the List_Boxes:
    
          ;; List_Box 'lst1'
         
          (UpdateList "lst1" (mapcar 'car Data))
          (set_tile "lst1" *Name*)
    
          ;; List_Box 'lst2'
    
          (UpdateList "lst2" (cadr (nth (atoi *Name*) Data)))
          (set_tile "lst2" *Address*)
    
          ;; Action_tile Statements:
          ;; These control what happens when the user interacts with a tile in the dialog.
    
          (action_tile "lst1"
            (strcat
              "(UpdateList \"lst2\" (setq lst2 (cadr (nth (atoi (setq *Name* $value)) Data))))"
              "(setq *Address*"
              "  (set_tile \"lst2\""
              "    (if (< (atoi *Address*) (length lst2)) *Address* \"0\")"
              "  )"
              ")"
            )
          )
    
          ;; Here, when the user selects an item from 'lst1', the UpdateList subfunction
          ;; is fired to update the items in list_box 'lst2'.
    
          ;; list_box 'lst2' is also set to the value of *Address* if the index is
          ;; available for the selected item, else the first item is selected.
    
          ;; Note that $value is a string containg the index of the item
          ;; that the user has selected.
    
          (action_tile "lst2" "(setq *Address* $value)")
    
          ;; Dialog setup, lets start it:
    
          (start_dialog)
          (setq dclHandle (unload_dialog dclHandle))
        )
      )
      (princ)
    )
    
    
    
    dcl
    
    // DCL File to be saved as building.dcl
    
    lbox : popup_list { width = 50; fixed_width = true; alignment = centered; }
    
    building  : dialog { label ="Building"; spacer;
      : row {
        : lbox { key = "lst1"; label = "Name" ; }
        : lbox { key = "lst2"; label = "Address"; }
      }
      ok_only;
    }
    Last edited by rkmcswain; 2016-09-16 at 11:44 AM. Reason: Added [CODE] tags

  5. #15
    Member
    Join Date
    2016-01
    Posts
    46
    Login to Give a bone
    0

    Default Re: Need Lisp For Feets to Meters with 2 decimals only

    Quote Originally Posted by Manderson View Post
    HI I am trying to change existing drawing properties values in AUTOCAD with pop list below and just cant get there. Is there anyone who could help edit the code.
    Dear Sir,

    I appreciating you for preparing. with help of your lisp showing error as shown in image.

    Thank you,
    Best wishes.
    Attached Images Attached Images

Page 2 of 2 FirstFirst 12

Similar Threads

  1. 2015: Extra decimals in dimensions
    By dfi in forum Revit Architecture - General
    Replies: 2
    Last Post: 2015-10-27, 04:15 PM
  2. Converting to decimals of a foot
    By jmctamney in forum AutoCAD Fields
    Replies: 3
    Last Post: 2007-03-27, 06:18 AM
  3. Does anybody have a menu that shows fractions & decimals
    By papaj1232001 in forum AutoCAD Customization
    Replies: 4
    Last Post: 2006-09-09, 10:45 PM
  4. Replies: 6
    Last Post: 2006-02-21, 03:21 PM
  5. Rounding Decimals...
    By droak in forum AutoCAD General
    Replies: 1
    Last Post: 2004-08-06, 10:25 PM

Posting Permissions

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