Autocad Slot Command

 

Step 2: Draw a circle at 0,0 of 5mm radius. Step 3: Draw anothrer circle of same radius at 10,0. Step 4: Select rectangle tool. Step 5: Ctrl+Right click in the workspace. Step 6: Select the quadrant point of the circle. Step 7: Again Ctrl+Right click and then quadrant. Step 8: To the other quadrant. Step 9: Use region command. Press Esc few times to end line command. Repeat step 9 for the bottom line of the slot. Press Esc few times to end line command. Click Trim, select both horizontal line for trimming edge. Select object to trim, click on both inner circle edge. Press Esc few times to end trim command and your slot is done. 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.

Introduction To AutoCad Window and Toolbars used for 2D/3D Drafting CAD Tut 4. Do this Initial Setting Before Starting any AutoCad Drawings. 25 Tips and Tricks For Preparation And Crack Gate 2019 Examination CADTut.1 Introduction to AutoCAD and Its advantages- AutoCAD Software Information Autocad 2017 Free Download – Autocad Student Version How to open bak file in autocad- AutoCAD.

Autocad slot command tool
Lesson1
Sampleprogram, 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.

Autocad Slot CommandAutocad slot command blocks

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.

Tool

Autocad Slot Command Block

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 Tool

; 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 Centers
a1/a2 Endpoints of arc around a
b1/b2 Endpoints of arc around b
ang Angle of slot centerline
obm Old blipmode setting, 0 or 1
r Radius of arcs
w 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 --------

Autocad Slot Command Tutorial

Explanation

Autocad slot command block
The comment section
The 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 sections
There 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 1
The 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 2
Since 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 3
The 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 4
The 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 5
The 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 6
The setvar function turns blipmode on by setting system variable 'blipmode'to 1.
Lines 7
The 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 8
The 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 10
Same 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 11
The 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 12
The angle function returns the angle (in radians) between centers a andb, which is then assigned to variable ang.
Line 13
This 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, 16
Similar 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 17
The 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 18
The 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 19
Command echo is turned back on.
Line 20
Blipmode is set back to the setting it had before the program was run. The value of variable obm was set in line 2.
Line 21
Without 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 22
This final parenthesis closes off the first opening parenthesis which isfound before the defun function in line 1.

Autocad Slot Command


HOME

Autocad Slot Command Blocks

Copyright ©1988, 1998 Ronald W. Leigh