Revising-the-Program-Code

Revising the Program Code

Revising the Program Code

Now that you have seen how to use association lists in AutoLISP code, you can use
this method in writing the completed version of the gp:getPointInput function. Using the following code, replace or modify the version of gp:getPointInput you previously saved in gpmain.lsp.

NOTE:If you need or want to type the code into gpmain.lsp, rather than copy it from another file, you can save time by leaving out the comments
(all lines that begin with semicolons). But don’t get used to the idea of writing
code without comments!

;;;--------------------------------------------------------------;
;;;     Function: gp:getPointInput                               ;
;;;--------------------------------------------------------------;
;;;  Description: This function asks the user to select three    ;
;;;               points in a drawing, which will determine the  ;
;;;               path location, direction, and size.            ;
;;;--------------------------------------------------------------;
;;;  If the user responds to the get functions with valid data,  ;
;;;  use startPt and endPt to determine the position, length,    ;
;;;  and angle at which the path is drawn.                       ;
;;;--------------------------------------------------------------;
;;;  The return value of this function is a list consisting of:  ;
;;;   (۱۰ . Starting Point) ;; List of 3 reals (a point) denoting ;
;;;                         ;;  starting point of garden path.   ;
;;;   (۱۱ . Ending Point)   ;; List of 3 reals (a point) denoting ;
;;;                         ;;  ending point of garden path.     ;
;;;   (۴۰ . Width)          ;; Real number denoting boundary     ;
;;;                         ;;  width.                           ;
;;;   (۴۱ . Length)         ;; Real number denoting boundary     ;
;;;                         ;;  length.                          ;
;;;   (۵۰ . Path Angle)     ;; Real number denoting the angle    ;
;;;                         ;;  of the path, in radians.         ;
;;;--------------------------------------------------------------;
(defun gp:getPointInput	(/ StartPt EndPt HalfWidth)
  (if (setq StartPt (getpoint "
Start point of path: "))
    (if      (setq EndPt (getpoint StartPt "
Endpoint of path: "))
      (if (setq HalfWidth (getdist EndPt "
half-width of path: "))
         ;; if you've made it this far, build the association list
         ;; as documented above.  This will be the return value
         ;; from the function.
         (list
           (cons 10 StartPt)
           (cons 11 EndPt)
           (cons 40 (* HalfWidth 2.0))
           (cons 50 (angle StartPt EndPt))
           (cons 41 (distance StartPt EndPt))
) ) ) ) )

Next, you need to update the main function, C:GPath, in gpmain.lsp. Modify it to look like the following code:

(defun C:GPath (/ gp_PathData)
  ;; Ask the user for input: first for path location and
  ;; direction, then for path parameters.  Continue only if you
  ;; have valid input.  Store the data in gp_PathData.
  (if (setq gp_PathData (gp:getPointInput))
    (if      (gp:getDialogInput)
      (progn
            ;; At this point, you have valid input from the user.
            ;; Draw the outline, storing the resulting polyline
            ;; pointer in the variable called PolylineName.
            (setq PolylineName (gp:drawOutline))
            (princ "
The gp:drawOutline function returned <")
            (princ PolylineName)
            (princ "")
            (Alert "Congratulations - your program is complete!")	
        ) ;_ end of progn
       (princ "
Function cancelled.")
    ) ;_ end of if
    (princ "
Incomplete information to draw a boundary.")
  ) ;_ end of if
 (princ)				; exit quietly
);_ end of defun

If you are copying and pasting the code, add the following comments as a header preceding
C:GPath:

;;;**************************************************************;
;;;     Function: C:GPath        The Main Garden Path Function   ;
;;;--------------------------------------------------------------;
;;;  Description: This is the main garden path function. It is a ;
;;;               C: function, meaning that it is turned into an ;
;;;               AutoCAD command called GPATH. This function    ;
;;;               determines the overall flow of the garden path ;
;;;               program.                                       ;
;;;**************************************************************;
;;; The gp_PathData variable is an association list of the form: ;
;;;  (۱۰ . Starting Point) - List of 3 reals (a point) denoting  ;
;;;                           starting point of the garden path. ;
;;;  (۱۱ . Ending Point)   - List of 3 reals (a point) denoting  ;
;;;                           endpoint of the garden path.       ;
;;;  (۴۰ . Width)          - Real number denoting boundary       ;
;;;                           width.                             ;
;;;  (۴۱ . Length)         - Real number denoting boundary       ;
;;;                           length.                            ;
;;;  (۵۰ . Path Angle)     - Real number denoting the angle of   ;
;;;                           the path, in radians.              ;
;;;  (۴۲ . Tile Size)      - Real number denoting the size       ;
;;;                           (radius) of the garden path tiles. ;
;;;  (۴۳ . Tile Offset)    - Spacing of tiles, border to border. ;
;;;  ( ۳ . Object Creation Style)                                ;
;;;                        - Object creation style indicates how ;
;;;                          the tiles are to be drawn.  The     ;
;;;                          expected value is a string and one  ;
;;;                          one of three values (string case    ;
;;;                          is unimportant):                    ;
;;;                              "ActiveX"                       ;
;;;                              "Entmake"                       ;
;;;                              "Command"                       ;
;;;  ( ۴ . Polyline Border Style)                                ;
;;;                        - Polyline border style determines    ;
;;;                          the polyline type to be used for    ;
;;;                          path boundary.  The expected value  ;
;;;                          one of the following (string case is;
;;;                          unimportant):                       ;
;;;                              "Pline"                         ;
;;;                              "Light"                         ;
;;;**************************************************************;

To test the code revisions

  1. Save the updated file.
  2. Use the Check feature to search for any syntactical errors.
  3. Format the code, to make it more readable.
  4. Load the code, so that Visual LISP redefines the earlier versions of the functions.
  5. To run the program, enter (c:gpath) at the Console prompt.

If the program does not run successfully, try fixing it and running it again. Repeat
until you are too frustrated to continue. If all else fails, you can copy the correct
code from the TutorialVisualLISPLesson2 directory.

Learning AutoCad

w that you have seen how to use association lists in AutoLISP code, you can use this method in writing the completed version of the gp:getPointInput function.… You are here: Home / Compliance Programs / Revising Your Code of … attention on reviewing or revising their companies' codes of conduct.Code of Conduct is the single most important element of your ethics and compliance program. It sets the tone and direction for the entire function. Often, the …revision control or source control, is the management of changes to documents, computer programs, large web …. For source code control, the working copy is instead a copy of all files in a particular revision, generally stored locally on the …code to explain its purpose. … this is the method that the JVM looks for and provides the entry point of your program.… We are soliciting public input on whether and how we might revise the current Ticket to Work program rules. … BILLING CODE ۴۱۹۱-۰۲-P …Program · Electronic Reporting · Revisions and Withdraws … When submitting a revision to a TRI Form R, TRI-MEweb requires the user to … In this case, TRI-MEweb will automatically select this revision code.revision cycle proceeds according to a published schedule which includes final … responsible for developing and updating all NFPA codes and standards.programming languages, assemblers, translators, compilers, interpreters and IDEs for GCSE Computer … An IDE (integrated development environment) is used to write code, test for errors and translate a program. Revise ; Test. <. >.revising SPJ's Code of Ethics began in earnest following the 2013 Excellence in Journalism conference in August 2013. The 18-member committee  …

نظرات کاربران



درباره نویسنده



بنده سیامک دوستداری فارغ التحصیل رشته مکانیک سنگ از دانشگاه صنعتی اصفهان هستم، و در این وبسایت آموزش های مربوط به نحوه برنامه نویسی در اتوکد و هچنین آموزش تصویری دستورات اتوکد را قرار خواهم داد.

تلفن همراه: ۰۹۰۰۱۲۳۴۴۴۴

ایمیل: s.doostdari@gmail.com

ترفند های اتوکد



دسته بندی مطالب​