Autocad Slot Command

2021年1月13日
Download: http://gg.gg/ntxe2
slot routine
*Autocad Slot Command Block
*Autocad Slot Command Tutorial
*Autocad Slot Command Blocks
*Autocad Slot Command Tool
*Autocad Slot Commandslot routine
OOPS command 16. Will close the two lines with a semicircle. Handy for drawing slots. ERASE and enter selected object and hit enter Docked Tool Bar Array Command Fillet two parrallel lines 17. A connected sequence of of line and arc segments that is treated by AutoCAD as a single object. Mirror Polyline (Pline) MIRRTEXT= 1 Polygon 18. The command window and the ribbon complement each other i.e. You can type commands on the command line or click on the ribbon icons. However the command prompts that appear on the command window prevent the user from getting confused. Status Bar The status bar is a thin strip of the AutoCAD window found between the command window and the.i have been trying to create a lisp program that will draw a slot but am having problems with it not sure where the problem isit will not draw the slot to correct sizeany help would be appricatedthanks(defun C:SLOT (/ A B B1 B2 C D PW) (setq PW (getvar’PLINEWID’)) (initget 1) (setq B1 (getdist ’nLength of slot: ’)) (setq B2 (/ B1 2.0)) (setq B (list B2 0.0)) (initget 1) (setq C (list 0.0 (getdist ’nWidth of slot: ’))) (initget 1) (while (setq A (getpoint ’nInsertion point: ’)) (setq D (list (- (car A) (/ (car B) 2)) (- (cadr A) (/ (cadr C) 2)))) (setvar ’PLINEWID’ 0) (command ’_.pline’ D (mapcar ’+ D B) ’_a’ (mapcar ’+ D B C) ’_l’ (mapcar ’+ D C) ’_a’ ’_cl’) );while (setvar ’PLINEWID’ PW) (princ)) Autocad Slot Command BlockLesson1Sampleprogram, mslot
This first lesson is merely a sampleAutoLISP program with each line numbered and explained. Its purposeis simply to provide a first introduction to the ’look and feel’ of anAutoLISP program.
The program is called mslot (whichis short for ’milled slot,’ as shown above). The program asks theuser to enter the width of the slot (the diameter of the milling cutter),then to locate the centers at both ends of the slot. The programthen creates the 2D profile view of the milled slot using a closed polylinewith two straight segments and two arc segments, as shown below.
Since this is the first sample program,it has been kept very simple. There are several things that wouldbe added if it were written as a ’finished’ and ’fool proof’ program. (For example, it would offer a carry-over default diameterforthe slot. Also, it would have an error routine.) However, eventhough it is simple, it is still a practical program which adds a new capabilityto AutoCAD.
These lessons are sprinkled withsamples of programming code -- sometimes just a single line, other timesseveral lines. However, when a complete program is given, the beginningand end are marked with green marker lines, as below. You shouldnot only study this program, but also try it out as explained in the ’Introduction’one page back (see ’Fifteen Lessons’).
------marker ------ beginning of working program ------ try it out ------Autocad Slot Command Tutorial
;| MSLOT, short for Milled SLOT Copyright © 1998 Ronald W. Leigh Requests width and two center points. Draws a polyline with two straight and two arc segments.Variables:a/b Centersa1/a2 Endpoints of arc around ab1/b2 Endpoints of arc around bang Angle of slot centerlineobm Old blipmode setting, 0 or 1r Radius of arcsw Width of slot|;
(defun c:mslot (/ a a1 a2 ang b b1 b2 obm r w) ;line 1(setq obm (getvar ’blipmode’)) ;line 2(initget 7) ;line 3(setq w (getreal ’nWidth of slot: ’)) ;line 4(setq r (/ w 2)) ;line 5(setvar ’blipmode’ 1) ;line 6(initget 1) ;line 7(setq a (getpoint ’nLocate first center: ’)) ;line 8(initget 1) ;line 9(setq b (getpoint a ’nLocate second center: ’)) ;line 10(setvar ’blipmode’ 0) ;line 11(setq ang (angle a b)) ;line 12(setq a1 (polar a (- ang (/ pi 2)) r)) ;line 13(setq a2 (polar a (+ ang (/ pi 2)) r)) ;line 14(setq b1 (polar b (- ang (/ pi 2)) r)) ;line 15(setq b2 (polar b (+ ang (/ pi 2)) r)) ;line 16(setvar ’cmdecho’ 0) ;line 17(command ’.pline’ a1 b1 ’A’ b2 ’L’ a2 ’A’ ’CL’) ;line 18(setvar ’cmdecho’ 1) ;line 19(setvar ’blipmode’ obm) ;line 20(princ) ;line 21) ;line 22
-------- marker-------- end of working program -------- try it out --------
ExplanationAutocad Slot Command BlocksThe comment sectionThe section of the program above thenumbered lines is the comment section. These comments state the nameand purpose of the program, the variables, etc. When you load thisfile into AutoCAD, the load function does not place comments in memory. Comments can be included in two different ways. They can be placedbetweenthe two two-character combinations (semicolon-fence, and fence-semicolon)similar to the twelve lines at the beginning of this program, or they canbe placed after a single semicolon similar to the twenty-twoline numbers.Program sectionsThere are five sections in the program proper. Lines 1-2, Prepare: (program name, local variables, saving system variable setting) Lines 3-11, Get input: (width of slot, location of both centers) Lines 12-16, Calculate: (determineendpoints of polyline segments) Lines 17-19, Draw: (use thePLINE command to draw the slot) Lines 20-22, Reset: (restoresystem variable setting)Line 1The program proper starts at line 1. The opening parenthesis beforedefun matches the very last closing parenthesis and thus encloses the entireprogram. The defun function defines the program name, which in thiscase is c:mslot. This name is the symbol by which the program willbe called. The c: makes this a program to be called at AutoCAD’scommand prompt, and has nothing to do with Drive C. To run the program,only MSLOT is entered at the command prompt. The list of variablesstarts with a forward slash, which make all the variables local.Line 2Since the program is going to turn blipmode on and off (see lines 6 and11), the program runs the risk of changing the setting that the user hadpreviously selected for blipmode. To avoid this, the value of blipmodeneeds to be saved so it can be restored by the setvar function in line20. The inner expression (getvar ’blipmode’) is executed first. Thisexpression retrieves the current setting of the ’blipmode’ system variable,which will be either 0 (for ’off’) or 1 (for ’on’). Then the setqfunction assigns this value to the variable obm.Line 3The initget function initializes the next getreal function (in line 4)so that the user must enter a number rather than merely hitting ’Enter’. (Hitting ’Enter’ would cause the getreal function to return nil, whichwould then be assigned to variable w, which would cause the program tocrash in line 5.) The initget setting of 7 also keeps the user fromentering either zero or a negative number for the width of the slot.Line 4The getreal function prompts the user for the width of the slot. After the user enters a number, the setq functions assigns that numberto variable w. The ’n’ in front of the prompt forces the promptto appear at the left margin, at the beginning of a new line.Line 5The value in variable w (the width) is divided by 2 and assigned to variabler (radius). Notice that, in the expression which divides the widthby 2 (/ w 2), the divide function (indicated by the forwardslash) comes first. This is known as prefix notation. (By theway, don’t confuse this forward slash with the one found in line 1. There it indicates local variables. Here it indicates the divisionfunction.)Line 6The setvar function turns blipmode on by setting system variable ’blipmode’to 1.Lines 7The initget function initializes the next getpoint function (in line 8)so that the user must indicate a point rather than merely hitting ’Enter’. (Hitting ’Enter’ would cause the getpoint function to return nil, whichwould then be assigned to variable a, which would cause the program tocrash in line 10.)Line 8The getpoint function pauses and prompts the user to locate the first center. This location (actually a list of the three coordinates of the point) isthen assigned to variable a by the setq function.Lines 9(see line 7)Line 10Same as line 8 except the getpoint function has as its first argument thevariable a. If the user enters the two centers on screen rather thanusing the keyboard, this first argument connects a rubber-band cursor topoint a as the user moves the cursor to point b.Line 11The setvar function turns blipmode off so that later (in line 18) the pointssubmitted to the PLINE command will not place blips on the screen.Line 12The angle function returns the angle (in radians) between centers a andb, which is then assigned to variable ang.Line 13This line calculates the location of point a1 by using the polar function. The polar function uses a base point, an angle, and a distance. Thebase point is a. The angle is 90 degrees less than ang, but the polarfunction needs radians so the expression (/ pi 2) is used inplace of 90. The distance is the radius of the arc, stored in variabler.Lines 14, 15, 16Similar to line 13, except in lines 15 and 16 variable b is used as thebase point, and in lines 14 and 16 the ’90 degrees’ (/ pi 2) is added toang rather than subtracted.Line 17The setvar function is used to turn system variable ’cmdecho’ (commandecho) off. This is done so that the next line, which draws a four-segmentpolyline, will not echo the PLINE prompts to the screen.Line 18The command function submits all of its arguments to the AutoCAD commandinterpreter. In effect, it runs the PLINE command and then submitsthe same information you would submit if you were running the PLINE commandfrom the keyboard, namely, point a1, point b1, ’A’ for arc mode, pointb2, ’L’ for line mode, point a2, ’A’ for arc mode, and finally ’CL’ forclose. The dot in front of the PLINE command forces AutoCAD to useits built-in PLINE command (just in case someone has undefined PLINE).Line 19Command echo is turned back on.Line 20Blipmode is set back to the setting it had before the program was run. The value of variable obm was set in line 2.Line 21Without this line, the last function in the program would be the setvarfunction which would return a number (0 or 1) which would be echoed tothe screen. The princ function echoes nothing, and thus providesa ’clean exit’ for the program.Line 22This final parenthesis closes off the first opening parenthesis which isfound before the defun function in line 1.Autocad Slot Command Tool
HOMEAutocad Slot CommandCopyright ©1988, 1998 Ronald W. Leigh
Download: http://gg.gg/ntxe2 https://diarynote.indered.space

コメント

お気に入り日記の更新

テーマ別日記一覧

まだテーマがありません

この日記について

日記内を検索