Sei sulla pagina 1di 16

substr - This function retrieves part of a string.

Syntax : (substr "string" startPoint numberOfCharacters)

strcase - This function converts to upper or lower case.


Syntax : (strcase "string" flag) flag = T or nil

strlen - This function returns the length of a string in characters.


Syntax : (strlen "string")

strcat - This function adds multiple strings together to form one string.
Syntax : (strcat "string1" "string2" "string3" ....ect. )

abs - This function returns the absolute value of a number.


Syntax : (abs number)

atoi - This function converts a string to a integer.


Syntax : (atoi "string")

itoa - This function converts an integer to a string.


Syntax : (itoa integer)

atof - This function converts a string to real.


Syntax : (atof "string")

fix - This function converts a real to an integer.


Syntax : (fix real)

float - This function takes a number (integer or real) and converts it to a real number.
Syntax : (float integer) (float real)

car - This function returns the first item of a list.


Syntax : (car list)

The item can be a list as shown in example 3 below.

cdr - This function returns a list that includes everything but the first item in a list.
in example 3 below.

The item can be a list as shown

Syntax : (cdr list)

cadr

- This function returns the second item in a list. The item can be a list as shown in example 3 below.

Syntax : (cadr list)

caddr

- This function returns the third item in a list. The item can be a list as shown in example 3 below.

Syntax : (caddr list)

caar

- This function returns the first item of the first item in a list. The item can be a list as shown in example 3 below.

Syntax : (caar list)

cddr - This function returns a list that includes everything after the second item in a list.
Syntax : (cddr list)

foreach - This function steps through each item in the list and returns the last value.
Syntax : (foreach varName list yourFunctions)

list

- This function creates a list. Syntax : (list Item) Syntax : (list firstItem secondItem) Syntax : (list firstItem secondItem thirdItem...)

cons

- This function takes an item and a list, and returns the addition of that item to the beginning of the list. The first item can be an atom or a list. Syntax : (cons Item list) ;thanks tim!

nth

- This function returns the Nth item in a list. The first item in a list is item zero. Syntax : (nth integer list)

fix - This function returns an integer.


Syntax : (fix number)

(NOTE: This function does not round numbers off!)

float - This function returns a real number.


Syntax : (float number)

rtos - This function converts numbers to a formatted string representing a distance.


Syntax : (rtos number mode precision) mode = 1 = Scientific with precision = 1 (rtos 456.5 1 1) returns "4.6E+02" mode = 2 = Engineering with precision = 1 (rtos 456.5 2 1) returns "456.5" mode = 3 = Decimal with precision = 1 (rtos 456.5 3 1) returns "38'-0.5"" mode = 4 = Architectural with precision = 1 (rtos 37.7071 4 1) returns "3'-1 1/2"" mode = 5 = Inch Fractional with precision = 1 (rtos 37.7071 5 1) returns "371/2""

angtos - This function converts a number to a formatted string representing an angle.


Syntax : (angtos number mode precision) mode = 0 = Decimal Degrees with precision = 1 (angtos 0.627102 0 1) returns "35.9" mode = 1 = Degrees Minutes Seconds with precision = 1 (angtos 0.627102 1 1) returns " 35d56' " mode = 2 = Grads with precision = 1 (angtos 0.627102 2 1) returns "39.9g" mode = 3 = Radians with precision = 1 (angtos 0.627102 3 1) returns "0.6r" mode = 4 = Surveyor with precision = 1 (angtos 0.627102 0 1) returns "N 54d4' E"

- Addition.

Syntax : (+ number number)

/ *
1+

- Subtraction. Syntax : (- number number) - Division. Syntax : (/ number number) - Multiplication. Syntax : (* number number) - Returns value increased by one. Syntax : (1+ number)

1-

- Returns value decreased by one. Syntax : (1- number)

cos

- Returns the cosine of an angle expressed in radians. (Note: Radians are AutoCads angular units. A circle = 2*pi Syntax : (cos number) or 180 degrees = pi )

atan

- Returns the arctangent of a number in radians. (Note: Radians are AutoCads angular units. A circle = 2*pi Syntax : (atan number1 ....optional number2) or 180 degrees = pi )

sin

- Returns the sine of an angle expressed in radians. (Note: Radians are AutoCads angular units. A circle = 2*pi Syntax : (sin number) or 180 degrees = pi )

sqrt

- Returns the square root of a number. Syntax : (sqrt number)

expt

- Returns a number raised to a power.

Syntax : (expt number power)

entsel - This function prompts for the user to pick one entity.
Syntax : (entsel) Returns the entity's name and the point selected in a list. Example: (<Entity name: 3b40a08> (230.666 285.862 0.0))

ssget - This function prompts the user to select entities.


Syntax : (ssget) ;prompts the user for a selection set.

Syntax : (ssget mode) ;prompts the user for a selection set and sets mode to "W", "C", "L", and "P", corresponding to the Window, Crossing, Last, and Previous selection methods. Another optional mode value is "X", which selects the entire database. There are other modes, but this list contains the modes that will be used most often. Syntax : (ssget "W" ) Syntax : (ssget "C" ) Syntax : (ssget "L" ) Syntax : (ssget "P" ) Syntax : (ssget "X" ) ;prompts the user for a selection set using the Window mode. ;prompts the user for a selection set using the Crossing mode. ;Selects the last entity selected. ;Selects the previously selected entities. ;Selects all entities in the drawing.

Syntax : (ssget filter_List) or (ssget mode filter_List) filter_List - an association list containing valid filters for entities corresponding to the Entity DXF Group Codes. What did I just say? Entity DXF Group Codes? What the heck is that? Click here to find out. You can filter out enitites that do no match your criteria using the filter_List. If you only wanted entities that were on layer "STR" then you could add a filter list that looks like this: (setq myFilter(list (cons 8 "STR"))) ;returns ((8 . "STR")) (ssget "X" myFilter) or (setq myFilter(list (cons 0 "LINE")(cons 8 "STR"))) ;returns ((0 . "LINE")(8 . "STR")) (ssget "X" myFilter) ;returns a selection set containing only line entities on layer "STR" ;returns a selection set containing only entities on layer "STR"

Returns a selection set of entity names.

ssadd - This function does one of three things depending on how many arguments you send with it.
If you use the ssadd function with no arguments it will return a new selection set with no members. Example : (setq myNewSet(ssadd)) If you use ssadd with a name of an entity it will return a new selection set with only that one member. Example : (setq myNewSet(ssadd entityName)) If you use ssadd with a name of an entity and name of an selection set, it will add that entity to the set. Example : (setq myOldSet(ssadd entityName selectionSetName)) And return the selection set with the entity added to the set. Syntax : (ssadd) (ssadd entityName) (ssadd entityName SelectionSetName) Where entityName is a valid entity name returned by ssname or entsel. Where selectionSetName is a valid name of a selection set returned by setq.

ssdel - This function does the opposite of ssadd.

SSDEL removes an entity from a selection set.

Syntax : (ssdel entityName selectionSetName) Where entityName is a valid entity name returned by ssname or entsel. Where selectionSetName is a valid name of a selection set returned by setq. Returns a new selection set without the entity. Assuming en1 is a valid entity and en2 is not. Assuming ss1 is a valid selection set and ss2 is not. Assuming en3 is a valid entity name but is not part of any selection set. (ssdel en1 ss1) (ssdel en1 ss2) (ssdel en2 ss1) (ssdel en2 ss2) (ssdel en3 ss1) ;returns selection set without entity en. ;returns ERROR - Bad Argument Type ;returns ERROR - Bad Argument Type ;returns ERROR - Bad Argument Type ;returns nil

Note: If you filter correctly using the ssget "X" function, you shouldn't need ssdel.

sslength - This function returns the number of entities inside a selection set.
Syntax : (sslength selectionSetName) Where selectionSetName is a valid name of a selection set returned by setq. Returns a real number if the number is greater than 32,767, otherwise it returns an integer. The number, real or integer, represents the quantity of items inside the selection set. Assuming ss1 is a valid selection set containing 15 entities. Assuming ss2 is a valid selection set containing 1 entity. Assuming ss3 is a valid selection set containing no entities. Assuming ss4 is a valid selection set containing 40,000 entities. Assuming ss5 is not a valid selection set. (sslength ss1) (sslength ss2) (sslength ss3) (sslength ss4) (sslength ss5) ;returns 15 as an integer ;returns 1 as an integer ;returns 0 as an integer ;returns 40000.0 as a real number ;returns ERROR - Bad Argument Type

ssname - This function returns an entity name contained inside a selection set.
Syntax : (ssname selectionSetName nthItem) Where selectionSetName is a valid name of a selection set returned by setq. Where nthItem is an integer representing an index into the set. Note: nthItem needs to be a real if the set contains more than 32,767 items. Returns an entity's name on success and nil on error. Assuming ss1 is a valid selection set containing 15 entities. Assuming ss2 is a valid selection set containing 40,000 entities. Assuming ss3 is not a valid selection set. (ssname ss1 0) ;returns the first entity in the selection set.

(ssname ss1 3) (ssname ss1 24) (ssname ss1 -3) (ssname ss2 34555) (ssname ss2 34555.0)

;returns the fourth entity. ;returns nil ;returns nil ;returns ERROR - Bad Argument Type (needs real) ;returns the 34555th entity

entget - This function returns the DXF Group Codes of the entity.
Syntax : (entget ename) ename - a valid entity name returned by entsel, ssname, entlast, or the entnext function. Returns an Entity's DXF Group Codes as an association list. (setq en(car(entsel))) returns entity name as eg. <Entity name: 3b40a60> (entget en) returns : ((-1 . <Entity name: 3b40a60>) (0 . "LINE") (5 . "FC") (100 . "AcDbEntity") (67 . 0) (8 . "DIM") (100 . "AcDbLine") (10 252.578 68.25 0.0) (11 188.379 31.5 0.0) (210 0.0 0.0 1.0))

entlast - This function returns the name of the last non-deleted entity in the drawing.
Syntax : (entlast) This function is mainly used to get the last entity added to the drawing. Returns an entity name. (entlast) returns <Entity name: 3b40a60>

entnext - Let's look at AutoDesk's explanation:


name ename, it there is no next and subentities.

If entnext is called with no arguments, it returns the entity of the first nondeleted entity in the database. If entnext is called with an entity name argument returns the entity name of the first nondeleted entity following ename in the database. If entity in the database, it returns nil. The entnext function returns both main entities

seqend

The entities selected by ssget are main entities, not attributes of blocks or vertices of polylines. You can access the internal structure of these complex entities by walking through the subentities with entnext. Once you obtain a subentity's name, you can operate on it like any other entity. If you obtain the name of a subentity with entnext, you can find the parent entity by walking forward with entnext until a entity is found, then extracting the -2 group from that entity, which is the main entity's name.

Syntax : (entnext) or (entnext ename) ename - a valid entity name returned by entsel, ssname, entlast, or the entnext function. (entnext) returns the name of the first entity in the drawing. (entnext ename) returns the name of the next entity following ename.

entdel - This function deletes an entity from the drawing if it exist.


deleted, it will undelete the entity. Syntax : (entdel ename)

If it does not exist and has been previously

ename - a valid entity name returned by entsel, ssname, entlast, or the entnext function. Returns an entity name. (setq en(car(entsel))) returns the name of selected entity. (entdel en) deletes the entity and returns the name of the deleted entity. (entdel en) undeletes the entity and returns the name of the undeleted entity.

entmod - Modifies an entity in the AutoCAD database.


Syntax : (entmod elist) elist - a list that is returned from an entget statement. (DXF Group Codes of an entity) Returns an elist if successful otherwise it returns nil. (setq en(car(entsel))) returns the name of selected entity. (setq elist(entget en)) returns the DXF Group Codes of the entity. (setq elist(subst (cons 8 "DIM")(assoc 8 elist) elist)) The line above Replaces existing layer name in the elist with new layer name "DIM" (entmod elist) updates the AutoCAD database and replaces the old layer name with the new one.

entupd - Updates the screen image of an entity.


Syntax : (entupd ename)

ename - a valid entity name returned by entsel, ssname, entlast, or the entnext function. Returns an entity name. (setq en(car (entsel))) returns an entity name. (entupd ename) refreshes the entity on the graphics screen. Note: If you modify the DXF Group Codes of an entity, such as changing the layer (8 . "LAyerName"), you will not notice the change until you regenerate the entire drawing or use entupd to regenerate the entity.

open/close - Open a file and close a file.

That simple.

Syntax : (open "filename" mode) (close fileVarName) Where filename is any valid file or resource name. Where mode is either "r" , "w" , or "a". "r" - Read mode. Reads a file with either read-char or read-line. "w" - Write mode. Writes to a file with either write-char, write-line, princ, or print. "a" - Append mode. Appends to an existing file using write-char, write-line, princ, or print. Note: If the existing file is not found in append mode, autolisp will create a new empty file. Open Returns a file descriptor. Note: You must use (setq varNam(open "file" mode)) to enable closing of the file. Note: Writing the file does not occur until you use the close statement. . Example: (if (setq f(open "c:/acad/myfile.txt" "r")) (progn (while (setq txtLine(read-line f)) (princ txtLine) ) (close f) ) (princ "\n Error - File was not opened.")

read-line - This function reads a line of text from an open file.


Syntax : (read-line fileVar) Where fileVar is a valid variable name that represents an open file descriptor. Returns a text string. Assuming (setq f(open "text.txt" "r")) returned sucessfully. Assuming (setq g(open "text8.txt" "r")) failed. (read-line f) (read-line g) ;returns string from file ;returns Error - Bad Argument Type

write-line - This function writes a line of text to an open file.


Syntax : (write-line fileVar) Where fileVar is a valid variable name that represents an open file descriptor. Returns a text string. Assuming (setq f(open "text.txt" "r")) returned successfully. Assuming (setq g(open "text8.txt" "r")) failed. (write-line "Hello World" f) (write-line "Hello World" g) ;writes text to file and returns string "Hello World" ;returns Error - Bad Argument Type

Entity DXF Group Code Table


Entity Types: (Group Code 0)

LN = Line CI = Circle AD = AttDef PT = Point

AR = Arc

TR = Trace

SD = Solid

TX = Text

3DF = 3DFace

PL = PolyLine VT = Vertex

DM = Dimension AT = Attribute

IN = Insert

SQ = Seqend

|---------------------

Entity Type (Group Code 0)

-----------------------|

CODE

DESCRIPTION

LN PT CI

AR TR SD TX SH IN

AD AT PL VT DM 3DF SQ

-1

Entity Name (Primary) Entity Name (Secondary) Primary Text Value Name: Shape, Block, Tag Prompt String Handle (Hexadecimal String) LineType Name Text Style Name Layer Name

-1

-1

-1

-1

-1

-1

-1

-1

-1

-1

-1

-1

-1

-1

-1

-1

-2 1 2 3 5 6 7 8

-2 1 2 2 1 2 3 5 6 5 6 5 6 5 6 5 6 5 6 5 6 7 8 8 8 8 8 8 8 8 8 5 6 5 6 5 6 7 8 5 6 7 8 8 8 8 8 8 5 6 5 6 5 6 5 6 5 6 1 2 1 2

CODE

DESCRIPTION

LN PT CI

AR TR SD TX SH IN

AD AT PL VT DM 3DF SQ

X of Start or Insert Point X of Center Point 10 X of Corner Point X of Definition Point X of Elev. Point (2D Poly)

10

10 10 10 10 10

10

10

10

10

10

10

10 10 10

X of End or Insertion Point X of Corner Point 11 X of Alignment Point X of Middle Point of Dimension X of Corner Point 12 X of Insertion Point X of Corner Point 13 X of Definition Point X of Definition Point

11 11 11 11 11 11 11 12 12 12 13 13 13 14 13 12 11

14

CODE

DESCRIPTION

LN PT CI

AR TR SD TX SH IN

AD AT PL VT DM 3DF SQ

15 16

X of Definition Point X of Definition Point Y of Start or Insertion Point Y of Center Point 20 20 20 20 20 20 20 20 20 20 20 20

15 16

20

Y of Corner Point Y of Definition Point Y of Elev. Point (2D Poly) Y of End or Insert Point Y of Corner Point 21

20 20 20

21

21 21 21 21

21

21

Y of Alignment Point Y of Middle Point of Dimension

21

CODE

DESCRIPTION

LN PT CI

AR TR SD TX SH IN

AD AT PL VT DM 3DF SQ

Y of Corner Point 22 Y of Insert Point Y of Corner Point 23 Y of Definition Point Y of Definition Point Y of Definition Point Y of Definition Point Z of Start or Insert Point Z of Center Point Z of Corner Point Z of Definition Point Z of Elevation Point (2D Poly) 30 30 30 30

22

22 22

22

23

23 23 24 25 26 30 30 30 30 30 30

23

24 25 26

30

30

30 30

30

30

CODE

DESCRIPTION

LN PT CI

AR TR SD TX SH IN

AD AT PL VT DM 3DF SQ

Z of End Point Z of Corner Point 31 Z of Alignment Point Z of Middle Point of Dimension 32 Z of Corner Point Z of Insert Point Z of Corner Point 33 34 Z of Definition Point Z of Definition

31 31 31 31 31 31 31 32 32 32 33 33 33 34 33 32 31

Point

CODE

DESCRIPTION

LN PT CI

AR TR SD TX SH IN

AD AT PL VT DM 3DF SQ

35 36 38 39

Z of Definition Point Z of Definition Point Entity Elevation Entity Thickness Radius Height, Size, or Width Leader Length 38 39 38 39 38 39 40 38 39 40 40 40 40 40 40 38 39 38 39 38 39 38 39 38 38 39 38 39 38 39 39

35 36 38 39 38 39

40

40 41 41 42 43 44 41 41 41 41 42

41 42 43 44

X Scale Factor or Width Y Scale Factor or Bulge Z Scale Factor Column Spacing

CODE

DESCRIPTION

LN PT CI

AR TR SD TX SH IN

AD AT PL VT DM 3DF SQ

45 50

Row Spacing Rotation Angle Start Angle Curve Fit Tangent End Angle 51 51 51 Obliquing Angle Angle from Horizontal 50 50 50 50

45 50 50 50 50 51 51 51 62 62 62 62 62 62 62 62 62 66 62 62 62 66 70 70 70 70 70 62 62 62 62 50

51

62 66

Color Entities Follow Flag Dimension Type Vertex or Polyline Flag Attribute Flag

70

Column Count Invisible Edges Flag

70 70

CODE

DESCRIPTION

LN PT CI

AR TR SD TX SH IN

AD AT PL VT DM 3DF SQ

Text Generation Flag 71 Row Count Mesh M Vertex Count Text Justification 72 Mesh N Vertex Count Field Length 73 Smooth Surface M Density Smooth Surface N Denstiy Smooth Surface Type X of Extrusion Point Y of Extrusion Point

71

71 71

71

71 72 72 72 72 73 73 73 74 75 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210 210

74 75 210 220

Potrebbero piacerti anche