AutoLISP is a dialect of the programming language Lisp built specifically for use with the full version of AutoCAD and its derivatives, which include AutoCAD Map 3D, AutoCAD Architecture and AutoCAD Mechanical.
AutoLISP is a small, dynamically scoped, dynamically typed Lisp language dialect with garbage collection, immutable list structure, and settable symbols, lacking in such regular Lisp features as macro system, records definition facilities, arrays, functions with variable number of arguments or let bindings. Aside from the core language, most of the primitive functions are for geometry, accessing AutoCAD's internal DWG database, or manipulation of graphical entities in AutoCAD. (Wikipedia)
Cathedral is a collection of functions to be used in developing AutoLISP routines for AutoCAD. These functions provide
new functionality for data processing in AutoLISP like filter
, chunk
, string split
, intersect
, etc.
Start the project and share! ;P
Fork the project and create a Pull Request :)
or send a sugestion in Issues :)
Download or clone the project.
Add de root directory cathedral
in Suport File Search Path
of AutoCAD options
configutarion.
After you can load de file cathedral-load
(load path-to-cathedral-load-file)
Or add the file to load at AutoCAD initialization in appload
configuration.
And functions will be available from the autocad command line and its AutoLISP codes.
- Core
- Math
- String
- List
- Simple List
- Association List
- Block
- Files
Creates a function pipe by passing the result of a function as a last parameter to the next function.
If the functions receives multiple parameters, thar should be passed as a list.
list
: callbackList
: List of callback functions will be executed in the order they appear in the list.
any
: value
: Value to be processed.
any
: Result after the application of the functions on the value.
The code below receives a string and first passes to the stlen function that returns the string size, then passes that
result to the zerop function that checks whether it is a zero or not, thus checking whether the string is empty or not.
(|>> (list
strlen
zerop) "testing") ; nill
(|>> (list
strlen
zerop) "") ; T
The same of:
(zerop (strlen ""))
If the functions receives multiples params.
The example takes the list size, adds 5 and multiplies 2 by the result .
(setq lstElements '("a" "b" "c" "d"))
(|>> (list
length
'(+ 5)
'(* 2)) lstElements) ; 18
The same of:
(setq lstElements '("a" "b" "c" "d"))
(* 2 (+ 5 (length lstElements)))
Creates a function pipe by passing the result of a function as a first parameter to the next function.
If the functions receives multiple parameters, thar should be passed as a list.
list
: callbackList
: List of callback functions will be executed in the order they appear in the list.
any
: value
: Value to be processed.
any
: Result after the application of the functions on the value.
The code below receives a string and first passes to the stlen function that returns the string size, then passes that
result to the zerop function that checks whether it is a zero or not, thus checking whether the string is empty or not.
(|> (list
strlen
zerop) "testing") ; nill
(|> (list
strlen
zerop) "") ; T
The same of:
(zerop (strlen ""))
If the functions receives multiples params.
The example takes the list size, adds 5 and 4, and multiplies the result by 2.
(setq lstElements '("a" "b" "c" "d"))
(|> (list
length
'(+ 5 4)
'(* 2)) lstElements) ; 26
The same of:
(setq lstElements '("a" "b" "c" "d"))
(* (+ (length lstElements) 5 4) 2)
Return True (T) if first parameter is not equal to second parameter
any
: elo
: First parameter to compare
any
: elt
: Second parameter to compare
bool
: True (T) if first parameter is not equal to second parameter
Check if first parameter is not equal to second parameter
(not= 1 2) ; T
(not= 1 1) ; nill
Return True (T) if the parameter is not null
any
: elo
: Parameter to verify
bool
: True (T) if the parameter is not null
Check if the parameter is not null
(notnull 1) ; T
(notnull nil) ; nil
Returns True (T) if the parameter is negative
int
: elo
: Parameter to verify
bool
: True (T) if the parameter is negative
Check if the parameter is negative
(neg? 1) ; nill
(neg? 0) ; nil
(neg? -2) ; T
Returns True (T) if the parameter is even
int
: elo
: Parameter to verify
bool
: True (T) if the parameter is even
Check if the parameter is even
(even? 1) ; nill
(even? 2) ; T
Returns True (T) if the parameter is odd
int
: elo
: Parameter to verify
bool
: True (T) if the parameter is odd
Check if the parameter is odd
(odd? 1) ; T
(odd? 2) ; nil
Execute body if test is True (T).
exp
: test
: Logical test.
exp
: body
: Expression to execute.
any
: Return the result of execution body.
Sum if num is equal 1.
(setq num 1)
(when (= num 1)
(+ num 5)) ; 6
(setq num 2)
(when (= num 1)
(+ num 5)) ; nil
Execute body if test is False (nil).
exp
: test
: Logical test.
exp
: body
: Expression to execute.
any
: Return the result of execution body.
Sum if num is different 1.
(setq num 1)
(when-not (= num 1)
(+ num 5)) ; nil
(setq num 2)
(when-not (= num 1)
(+ num 5)) ; 7
Returns the type of entity.
Entity Name
: entity-name
: Entity name to get type.
string
: Type of the entity.
The code below receives a Entity name and return the type.
(setq entity-name <Entity name: 7ffffb0c8c0>) ; from (car (entsel)) for exemple
(type-entity entity-name) ; "INSERT"
Execute body if test is False (nil).
exp
: test
: Logical test.
exp
: body
: Expression to execute.
any
: Return the result of execution body.
Sum if num is different 1.
(setq num 1)
(if-not (= num 1)
(+ num 5)) ; nil
(setq num 2)
(if-not (= num 1)
(+ num 5)) ; 7
Return a string wit the current date and time in the format indicated.
The format is indicated by a parameter containing the options:
- Y -> indicates the year
- m -> indicates the month
- d -> indicates the day
- H -> indicates the hour
- i -> indicates the minutes
- s -> indicates the seconds
string
: format
: String indicating the format.
string
: String containing the date-time in the format indicated.
1 - Return the current data and time.
2 - Return just the current data.
3 - Return just the current time.
(date-time "Y-m-d H:i:s") ; "2019-06-12 23:57:13"
(date-time "Y-m-d") ; "2019-06-12"
(date-time "H:i:s") ; "23:57:13"
null-matrix? function check if the matrix argument is a null matrix.
list
: matrix
: Matrix to check.
bool
: If the matrix is a null matrix return T else return nill.
If the matrix is a null matrix return T else return nill.
(setq matrix '((1 2 3) (4 5 6)))
(null-matrix? matrix) ;; nill
(setq matrix '((0 0 0) (0 0 0)))
(null-matrix? matrix) ;; T
null-matrix function create a MxN null matrix.
int
: m
: Number of rows in the matrix.
int
: n
: Number of columns in the matrix.
list
: Null matrix MxN.
Return a Null matrix MxN.
(null-matrix 2 3) ; ((0 0 0) (0 0 0)
(null-matrix 4 4) ; ((0 0 0 0) (0 0 0 0) (0 0 0 0) (0 0 0 0))
square-matrix? function check if a matrix is an square matrix.
list
: matrix
: Matrix to check.
boll
: Return T if the matriz is a square matrix, else return nill.
Return T if the matriz is a square matrix, else return nill.
(setq matrix '((1 2 3) (4 5 6) (7 8 9)))
(setq matrix2 '((1 2 3) (4 5 6)))
(square-matrix? matrix) ; T
(square-matrix? matrix2) ; nill
Function diagonal-matrix? verify if the matrix is an diagonal matrix.
list
: matrix
: Matrix to check.
boll
: Return T if the matriz is a diagonal matrix, else return nill.
Return T if the matriz is a diagonal matrix, else return nill.
(setq matrix '((1 0 0) (0 5 0) (0 0 9)))
(setq matrix2 '((1 2 3) (4 5 6)))
(diagonal-matrix? matrix) ; T
(diagonal-matrix? matrix2) ; nill
Function nullify-diagonal-matrix nullify the main diagonal of a matrix.
list
: matrix
: Matrix to alter.
list
: Return a matrix with the main diagonal null (0).
Return a matrix with the main diagonal null.
(setq matrix2 '((1 2 3) (4 5 6) (7 8 9)))
(nullify-diagonal-matrix matrix) ; ((0 2 3) (4 0 6) (7 8 0)
Function main-diagonal-matrix get the items of a main diagonal matrix.
list
: matrix
: Matrix to get main diagonal.
list
: Return values of main diagonal matrix.
Return values of main diagonal matrix.
(setq matrix2 '((1 2 3) (4 5 6) (7 8 9)))
(main-diagonal-matrix matrix) ; (1 5 9)
identity-matrix? function checks if a matrix is identity matrix.
list
: matrix
: Matrix to check.
bool
: Return T if the matriz is identity matrix, else return nill.
Return T if the matriz is identity matrix, else return nill.
(setq matrix '((1 0 0) (0 1 0) (0 0 1))
(setq matrix2 '((1 2 3) (4 5 6) (7 8 9)))
(square-matrix? matrix) ; T
(square-matrix? matrix2) ; nill
identity-matrix returns an identity matrix.
int
: n
: Matrix size.
list
: Returns an identity matrix of size n.
Returns an identity matrix of size n.
(identity-matrix 4) ; ((1 0 0 0) (0 1 0 0) (0 0 1 0) (0 0 0 1))
(identity-matrix 3) ; ((1 0 0) (0 1 0) (0 0 1))
transpose-matrix returns the matrix transposed from a matrix.
list
: matrix
: Matrix to transpose.
list
: Returns the transposed matrix.
Returns the matrix transposed from a matrix.
(setq matrix '((1 2) (3 4) (5 6)))
(transpose-matrix matrix) ; ((1 3 5) (2 4 6))
+matrix function adds two matrices.
list
: matrix-a
: Matrix to sum.
list
: matrix-b
: Matrix to sum.
list
: Returns the sum of two matrices.
Returns the sum of two matrices.
(setq matrix-a '((1 2) (3 4) (5 6)))
(setq matrix-b '((1 2) (3 4) (5 6)))
(+matrix matrix-a matrix-b) ; ((2 4) (6 8) (10 12))
-matrix function subtracts two matrices.
list
: matrix-a
: Matrix to sub.
list
: matrix-b
: Matrix to sub.
list
: Returns the subtraction of two matrices.
Returns the sum of two matrices.
(setq matrix-a '((1 2) (3 4) (5 6)))
(setq matrix-b '((2 1) (8 4) (5 10)))
(-matrix matrix-a matrix-b) ; ((-1 1) (-5 0) (0 -4))
*smatrix function multiplies a scalar by an matrix.
int
: scalar
: Scalar to multiply.
list
: matrix
: Matrix to multiply.
list
: Returns a matrix resulting from multiplication.
Returns a matrix resulting from multiplication.
(setq matrix '((2 3) (4 6)))
(*smatrix 2 matrix) ; ((4 6) (8 12))
*matrix function multiplies two matrices.
list
: matrix-a
: Matrix to multiply.
list
: matrix-b
: Matrix to multiply.
list
: Returns a matrix resulting from multiplication.
Returns a matrix resulting from multiplication.
(setq matrix-a '((2 3) (4 6)))
(setq matrix-b '((1 2 0) (2 1 1)))
(*matrix matrix-a matrix-b) ; ((8 9 3) (16 18 6))
opposite-matrix function returns the opposite matrix from a matrix.
list
: matrix
: Matrix to get opposite.
list
: Returns the opposite matrix from a matrix.
Returns the opposite matrix from a matrix.
(setq matrix '((2 -3) (-4 6)))
(opposite-matrix matrix) ; ((-2 3) (4 -6))
*svector function multiplies a scalar by an vector.
int
: scalar
: Scalar to multiply.
list
: vector
: Vector to multiply.
list
: Returns a vector resulting from multiplication.
Returns a vector resulting from multiplication.
(setq vector '(2 4 6 8))
(*svector 2 vector) ; (4 8 12 16)
+vector function adds two vectors.
list
: vector-a
: vector to sum.
list
: vector-b
: vector to sum.
list
: Returns the sum of two vectors.
Returns the sum of two vectors.
(setq vector-a '(1 2 3))
(setq vector-b '(1 2 3)
(+vector vector-a vector-b) ; (2 4 6)
*i-vector function result in a internal product between two vectors.
list
: vector-a
: vector to process.
list
: vector-b
: vector to process.
list
: Returns a internal product between two vectors.
Returns a internal product between two vectors.
(setq vector-a '(2 3 ))
(setq vector-b '(4 3)
(*i-vector vector-a vector-b) ; 17
-vector function subtracts two vectors.
list
: vector-a
: vector to subtract.
list
: vector-b
: vector to subtract.
list
: Returns the subtraction of two vectors.
Returns the subtraction of two vectors.
(setq vector-a '(1 2))
(setq vector-b '(1 2)
(-vector vector-a vector-b) ; (0 0)
opposite-vector function returns the opposite vector of a vector.
list
: vector
: vector to preocess.
list
: Returns the opposite vector of a vector.
Returns the opposite vector of a vector.
(setq vector '(7 -3))
(opposite-vector vector) ; (-7 3)
norm-vector function returns the norm of a vector.
list
: vector
: vector to preocess.
int
: Returns the norm of a vector.
Returns the norm of a vector.
(setq vector '(3 -4))
(norm-vector vector) ; 5
det-matrix function returns the determinant from an matrix (matrix must be order 1, 2 or 3).
list
: matrix
: matrix to get determinant.
int
: Returns the determinant of an matrix.
Returns the determinant of an matrix.
(setq matrix '((2 1 0) (0 1 0) (1 2 1)))
(det-matrix matrix) ; 2
The str-split function splits a string into substrings by having a character as a reference.
string
: string
: String to be split.
string
: delimiter
: Character used as a delimiter for division.
list
: list-splits
: List with resulting substrings
Receives a string and splits into parts with a reference delimiter.
(str-split "testing-the-function" "-")
("testing" "the" "function")
The str-is-empty function return True (T) if string is empty ("") and Nil otherwise.
string
: string
: String to be check.
bool
: True (T) if string is empty ("") and Nil otherwise.
Receives a string and return True if the string is not empty ("").
(str-is-empty "testing") ; nil
(str-is-empty? "") ; T
The str-join function gets a list of string and joins these string abd returns a string only.
list
: list-string
: list-string : List of string.
string
: A string being the join of the string list.
Receives a list of string and return a string.
(str-join '("a" "b" "o" "u" "t"))
"about"
(str-join '("hello " "world"))
"hello world"
The str-left function take n characters from left side of a string.
int
: n
: Quantity of characters to take.
string
: string
: String to take n characters.
string
: A string containing n caracters.
Receives a int n and a string, return n characters of the left side string.
(str-left 2 "testing")
"te"
The str-right function take n characters from right side of a string.
int
: n
: Quantity of characters to take.
string
: string
: String to take n characters.
string
: A string containing n caracters.
Receives a int n and a string, return n characters of the right side string.
(str-right 2 "testing")
"ng"
Filter elements of a list using a callback function, the calback function should return T (true) for the element to
enter the new list and nil for the element not to enter the new list.
function
: calback
: Callback function.
list
: list-values
: List of elements to be filtered.
list
: List with elements filtered according to the callback function.
Example that filters a list of numbers and returns only even numbers.
(filter (lambda (num)
(= (rem num 2) 0)) '(1 2 3 4 5 6 7 8 9))
(2 4 6 8)
Divides a list into parts of the same size as the one received as a parameter.
If the size is negative, the list values are reversed.
integer
: size
: Size of the resulting sublists.
list
: list-values
: List to be divided.
list
: List containing the sublists.
Example divides a list into sublists of 4 elements.
(setq lista '(1 2 3 4 5 6 7 8 9))
(chunk 4 lista)
((1 2 3 4) (5 6 7 8) (9))
Returns the items in a list except those defined as a parameter.
list
: list-values
: List with all values.
list
: list-values-except
: List with values to be removed.
list
: List containing the values except those defined to be removed.
Example returns values from a list except those defined as a parameter.
(setq lista '(1 2 3 4 5 6 7 8 9))
(except lista '(2 5 7))
(1 3 4 6 8 9)
Returns the intersection of the elements of the first list with the elements of the second list.
list
: list-values-intersect
: List with the values to be searched for.
list
: list-values
: List with values to be tested.
list
: List containing the intersection of the first list with the second list.
Example that returns the intersection of the first list in the second.
(setq firstList '(1 4 6 9))
(setq secondList '(1 2 3 5 7 8 9))
(intersect firstList secondList)
(1 9)
Return True (T) if Callback return True for every items in list-values.
function
: callback
: Function to be applied to all items.
list
: list-values
: List of values.
bool
: True (T) if Callback is True for every items.
Check if all numbers are odd.
(every? odd? '(1 3 5 7)) ; T
(every? odd? '(1 2 5 4)) ; nill
Return False (nil) if Callback return True for every items in list-values.
function
: callback
: Function to be applied to all items.
list
: list-values
: List of values.
bool
: False (nill) if Callback is True for every items.
Check if all numbers are odd.
(not-every? odd? '(1 3 5 7)) ; nill
(not-every? odd? '(1 2 5 4)) ; T
Execute a function reducer to alements in list.
function
: callback
: Function reducer to be applied to all items.
list
: list-values
: List of values.
any
:
Sum all items in a list.
(reduce + '(1 2 3)) ; 6
Return False (nil) if Callback return True for any item in list-values.
function
: callback
: Function to be applied to items.
list
: list-values
: List of values.
bool
: False (nill) if Callback is True for any item.
Check if exist one numbers odd.
(not-any? odd? '(1 3 5 7)) ; nil
(not-any? odd? '(1 2 6 8)) ; T
Return True (T) if the list-values contains de value find.
any
: find
: value to look for.
list
: list-values
: List of values.
bool
: True (T) if exist value in list.
Check if exist value 2 in list.
(contains? 2 '(5 3 8 2 9)) ; T
(contains? 2 '(5 3 8 14 9)) ; nil
Take the count first element from a list.
If the count is negative, the take element from the end of list.
int
: count
: value to look for.
list
: list-values
: List of values.
list
: List of the count n elements from list.
Check if exist value 2 in list.
(take 2 '(5 3 8 2 9)) ; (5 3)
Return the first element of a list, like car.
list
: list-values
: List of values.
any
: First element of a list.
Return the first element of a list.
(first '(5 6 2 7 9 8)) ; 5
Returns the elements of a list except the first item, like cdr.
list
: list-values
: List of values.
list
: Elements of a list except the first item.
Returns the elements of a list except the first item.
(rest '(5 6 2 7 9 8)) ; (6 2 7 9 8)
Returns a list of elements where the passed function returns True.
Stop when the function returns nil for any element.
function
: callback
: Function for test elements.
list
: list-values
: List of values.
list
: List of elements while returning function True.
Returns a list of elements while the function returned True.
(setq list-values '(-1 -2 -3 -4 8 9 3 7 -6 -3))
(take-while neg? list-values) ; (-1 -2 -3 -4)
Return a list of result application a callback function in elements of a list.
function
: callback
: Function for apply in elements.
list
: list-values
: List of values.
list
: List of result application function in elements of a list.
Sum 2 for each element in a list.
(setq list-values '(1 2 3 4 5))
(keep (lambda (x) (+ x 2)) list-values) ; (3 4 5 6 7)
Receives an association list and returns only the keys.
list
: association-list
: Association list to be processed.
list
: List containing all the keys in the association list.
Receives an association list and returns only the keys.
(setq ttt '(("a" 1) ("b" 2) ("c" 5) ("d" 8) ("e" 6) ("s" 9)))
(only-keys ttt)
("a" "b" "c" "d" "e" "s")
Receives an association list and returns only values.
list
: association-list
: Association list to be processed.
list
: List containing all the keys in the associoation list.
Receives an association list and returns only the keys.
(setq ttt '(("a" 1) ("b" 2) ("c" 5) ("d" 8) ("e" 6) ("s" 9)))
(only-values ttt)
(1 2 5 8 6 9)
Receives a list containing list of associations and returns the lists of associations that contain the key with the
value received by parameter.
any
: key
: Key to be sought.
any
: value
: Value to be filtered.
list
: association-list
: List to be processed.
list
: List containing the sublists that contain the key with the value received per parameter.
It receives a list with join sublists and returns only those that contain the key with the defined value.
(setq ttt '((("a" 1) ("b" 2) ("c" 3)) (("a" 1) ("b" 8) ("c" 5)) (("a" 3) ("b" 2) ("c" 52))))
(where "a" 1 ttt)
Return True (T) if the list association contains de key 'key'.
any
: key
: Key to look for.
list
: list-values
: List association of values.
bool
: True (T) if exist key in list.
Check if exist the key 2 in list.
(contains-key? 2 '((1 . "a") (2 . "b") (3 . "c"))) ; T
(contains-key? 2 '((1 . "a") (5 . "b") (3 . "c"))) ; nil
Return True (T) if the list association contains the value 'find'.
any
: find
: Value to look for.
list
: list-values
: List association of values.
bool
: True (T) if exist the value in list.
Check if exist the value "b" in list.
(contains-value? "b" '((1 . "a") (2 . "b") (3 . "c"))) ; T
(contains-value? "b" '((1 . "a") (5 . "h") (3 . "c"))) ; nil
Returns association list with the description and attribute value of a Block.
Entity Name
: entity-name
: Entity name of the block for extract the attributes.
list
: List association with description and values of the attributes.
The code below receives a Entity name from a Block and return a list of attributes.
(setq entity-name <Entity name: 7ffffb0c8c0>) ; from (car (entsel)) for exemple
(block-attr-values entity-name) ; (("SNAME" . "name block") ("ZSIZE" . "56") ("LFXYZ" . "0,0,0") ("BEAMDI" . "0.0") ("CONEDE" . "34") ("CONEAN" . "10.0") ("BIASMAX" . "-1"))
Returns the description from a attribute entity.
list
: data-attrib-entity
: List of data from a entity name get with (entget) for exemple.
string
: Description of the attribute entity.
Returns the value from a attribute entity.
Entity Name
: entity-name
: List of data from a entity name get with (entget) for exemple.
string
: Value of the attribute entity.
Returns only the description of the attributes of a block.
Entity Name
: entity-name
: Entity name of the block.
list
: List containing description of attributes.
The code below receives a Entity name and return a list of description attributes.
(setq entity-name <Entity name: 7ffffb0c8c0>) ; from (car (entsel)) for exemple
(block-attr entity-name) ; ("SNAME" "ZSIZE" "LFXYZ" "BEAMDI" "CONEDE" "CONEAN" "BIASMAX" "BIASMIN" "COLOR" "INTENSITY" "GNAME" "LAZ" "LAY" "LAX")
Returns only the values of the attributes of a block.
Entity Name
: entity-name
: Entity name of the block.
list
: List containing values of attributes.
The code below receives a Entity name and return a list of values attributes.
(setq entity-name <Entity name: 7ffffb0c8c0>) ; from (car (entsel)) for exemple
(block-values entity-name) ; ("name block" "56" "0,0,0" "0.0" "34" "10.0" "-1" "-1" "1,1,1" "1" "" "" "" "")
Returns the value corresponding to the attribute passed by parameter.
Entity Name
: entity-name
: Entity name of the block.
any
: Value of the attribute.
The code below receives a Entity name and a attribute and returne the value of attribute.
(setq entity-name <Entity name: 7ffffb0c8c0>) ; from (car (entsel)) for exemple
(block-value-by-attr entity-name "SNAME") ; "name block"
This function is used to prepare a "writer" so that we can write by default specific spreadsheet 1.
The "writer" function takes as a parameter the row and column of the cell to be written and the
content to be written.
For close file execute the "writer" function passing row or column = 0.
string
: file-path
: Excell file path.
function
: Function used to write to a file.
Write to a file in C:.
(setq writer-sheet (write-sheet-default "C:\\test.xlsx"))
(write-sheetr 1 1 "spreadsheet 1 by default, line 1 column 1")
(write-sheetr 1 2 "spreadsheet 1 by default, line 1 column 2")
; For save and close file.
(writer-sheet 0 0 "")
This function is used to prepare a "writer" so that we can write to a specific spreadsheet
an xlsx file for example, so we can just pass the cell coordinate and the content we want
to write to the file.
The "writer" function takes as a parameter the row and column of the cell to be written and the
content to be written.
This function allows the user to specify which worksheet to write and can use multiple
worksheets from the same file simultaneously.
For close file execute execute any "writer" function passing row or column = 0.
list
: sheet
: List obtained with the def-sheet function.
function
: Function used to write to a file.
Write to a file in C: using spreadsheet 1 and spreadsheet 2 simultaneously.
for this you must use the functions def-sheets
and def-sheet
.
(setq sheets (def-sheets "C:\\test.xlsx"))
(setq sheet1 (def-sheet sheets 1)) ; Get for especific spreadsheet 1
(setq sheet2 (def-sheet sheets 2)) ; Get for especific spreadsheet 2
(setq writer-sheet-1 (write-sheet sheet1)) ; Writer to especific spreadsheet 1
(setq writer-sheet-2 (write-sheet sheet2)) ; Writer to especific spreadsheet 2
(writer-sheet-1 1 1 "spreadsheet 1, line 1 column 1") ; Writing "spreadsheet 1, line 1 column 1" in cell of line 1 and coluns 1 of spreadsheet 1
(writer-sheet-1 2 1 "spreadsheet 1, line 2 column 1") ; Writing "spreadsheet 1, line 2 column 1" in cell of line 2 and coluns 1 of spreadsheet 1
(writer-sheet-2 1 1 "spreadsheet 2, line 1 column 1") ; Writing "spreadsheet 2, line 1 column 1" in cell of line 1 and coluns 1 of spreadsheet 2
(writer-sheet-2 1 2 "spreadsheet 2, line 1 column 2") ; Writing "spreadsheet 2, line 1 column 2" in cell of line 1 and coluns 2 of spreadsheet 2
; For save and close file.
(writer-sheet-1 0 0 "")
def-sheets return a list containing a VLA-OBJECT Sheets and a VLA-OBJECT _Workbook
for use with def-sheet
function.
string
: file-path
: Excell file path.
list
: List containing a VLA-OBJECT Sheets and a VLA-OBJECT _Workbook.
Return VLA-OBJECT Sheets and a VLA-OBJECT _Workbook from a file.
(setq sheets (def-sheets "C:\\test.xlsx")) ; (#<VLA-OBJECT Sheets 00000000033f7278> #<VLA-OBJECT _Workbook 0000000026d1f258>)
def-sheets return a list containing a VLA-OBJECT Sheets and a VLA-OBJECT _Workbook
for use with def-sheet
function.
list
: sheets
: List obtained with the def-sheets
function.
worksheet
: file-path
: Excell file path.
list
: List containing a specific VLA-OBJECT _Worksheet and a VLA-OBJECT _Workbook.
Return specific VLA-OBJECT _Worksheet and a VLA-OBJECT _Workbook from
list obtained with the def-sheets function.
(setq sheets (def-sheets "C:\\test.xlsx")) ; (#<VLA-OBJECT Sheets 00000000033f7278> #<VLA-OBJECT _Workbook 0000000026d1f258>)
; Get específic spreadsheet 1 and 2
(setq sheet1 (def-sheet sheets 1)) ; (#<VLA-OBJECT _Worksheet 0000000032928678> #<VLA-OBJECT _Workbook 0000000026d1f258>)
(setq sheet2 (def-sheet sheets 2)) ; (#<VLA-OBJECT _Worksheet 000000003267e238> #<VLA-OBJECT _Workbook 0000000026d1f258>)
This function is used to prepare a "reader" so that we can read by default specific spreadsheet 1.
The "reader" function takes as a parameter the row and column of the cell to be read.
For close file execute the "reader" function passing row or column = 0.
string
: file-path
: Excell file path.
function
: Function used to read to a file.
Read to a file in C:.
(setq reader-sheet (read-sheet-default "C:\\test.xlsx"))
(reader-sheet 1 1) ; "spreadsheet 1 by default, line 1 column 1"
(reader-sheet 1 2) ; "spreadsheet 1 by default, line 1 column 2"
; For close file.
(reader-sheet 0 0)
This function is used to prepare a "reader" so that we can read a specific spreadsheet of
an xlsx file for example, so we can just pass the cell coordinate and we want read the file.
The "reader" function takes as a parameter the row and column of the cell to be read.
This function allows the user to specify which worksheet to write and can use multiple
worksheets from the same file simultaneously.
For close file execute execute any "reader" function passing row or column = 0.
list
: sheet
: List obtained with the def-sheet function.
function
: Function used to read to a file.
Read to a file in C: using spreadsheet 1 and spreadsheet 2 simultaneously.
for this you must use the functions def-sheets
and def-sheet
.
(setq sheets (def-sheets "C:\\test.xlsx"))
(setq sheet1 (def-sheet sheets 1)) ; Ger for especific spreadsheet 1
(setq sheet2 (def-sheet sheets 2)) ; Ger for especific spreadsheet 2
(setq reader-sheet-1 (read-sheet sheet1)) ; Read to especific spreadsheet 1
(setq reader-sheet-2 (read-sheet sheet2)) ; Read to especific spreadsheet 2
(reader-sheet-1 1 1) ; "spreadsheet 1 lina 1 column 1"
(reader-sheet-1 2 1) ; "spreadsheet 1 lina 2 column 1"
(reader-sheet-2 1 1) ; "spreadsheet 2 lina 1 column 1"
(reader-sheet-2 1 2) ; "spreadsheet 2 lina 1 column 2"
; For save and close file.
(reader-sheet-1 0 0)
The function read-row-while-get reads the contents of the parameter row as long as it has contents in the columns.
If find a column without content stop the reading.
int
: row
: Line number for reading.
function
: reader-sheet
: "Reader" obtained with the read-sheet-default
or read-sheet
function.
list
: List containing the content read from the line in the file.
Read line from a file in C:.
(setq reader-sheet (read-sheet-default "C:\\test.xlsx"))
(read-row-while-get 1 reader-sheet) ; ("A" "B" "C" "D" "E")
(read-row-while-get 2 reader-sheet) ; ("Line 2 A" "Line 2 B" "Line 2 C" "Line 2 D" "Line 2 E")
; For close file.
(reader-sheet 0 0)
The function read-row-at reads the contents of the parameter row from the first column to the column
indicated in the second parameter, including empty columns.
int
: row
: Line number for reading.
int
: col-limit
: Indicates up to which column to read.
function
: reader-sheet
: "Reader" obtained with the read-sheet-default
or read-sheet
function.
list
: List containing the content read from the line in the file from column 1 to col-limit.
Read line from a file in C:.
(setq reader-sheet (read-sheet-default "C:\\test.xlsx"))
(read-row-at 1 5 reader-sheet) ; ("A" "B" "C" "D" "E")
(read-row-at 1 8 reader-sheet) ; ("A" "B" "C" "D" "E" "" "" "")
(read-row-at 2 7 reader-sheet) ; ("Line 2 A" "Line 2 B" "Line 2 C" "Line 2 D" "Line 2 E" "" "Line 2 G")
; For close file.
(reader-sheet 0 0)
The function read-col-while-get reads the contents of the parameter col as long as it has
contents in the rows. If find a row without content stop the reading.
int
: col
: Column number for reading.
function
: reader-sheet
: "Reader" obtained with the read-sheet-default
or read-sheet
function.
list
: List containing the content read from the rows in the file.
Read line from a file in C:.
(setq reader-sheet (read-sheet-default "C:\\test.xlsx"))
(read-col-while-get 1 reader-sheet) ; ("A" "F" "K")
(read-col-while-get 2 reader-sheet) ; ("B" "G" "L")
; For close file.
(reader-sheet 0 0)
The function read-col-at reads the contents of the parameter col from the first row
to the row indicated in the second parameter, including empty row.
int
: col
: Column number for reading.
int
: row-limit
: Indicates up to which row to read.
function
: reader-sheet
: "Reader" obtained with the read-sheet-default
or read-sheet
function.
list
: List containing the content read from the column in the file from row 1 to row-limit.
Read column from a file in C:.
(setq reader-sheet (read-sheet-default "C:\\test.xlsx"))
(read-col-at 1 5 reader-sheet) ; ("A" "F" "K" "" "")
; For close file.
(reader-sheet 0 0)