• This forum is the machine-generated translation of www.cad3d.it/forum1 - the Italian design community. Several terms are not translated correctly.

move an object according to coordinates placed in a table

  • Thread starter Thread starter anfaloni
  • Start date Start date

anfaloni

Guest
Bye to all,

I'm trying to get into the lisp to start working on it and automating myself. I wanted to ask you if you can do the following:

having a table excel imported in autocad, consisting of x rows and reporting on three different columns of the coordinates, I would like to make a lisp that covers x times an object falls in the drawing and moves it to point a,b,c where to b, there are variables that must take the values defined in the line of belonging of the cell excel.

I hope I've explained clearly. If I hadn't succeeded,
 
Sorry maybe I left in fourth....read more about reading a variable defined in a lisp a value belonging to an imported excel cell within the cad design would be an important first step. Do you have an idea how to do this?
 
1) start excel and open your file
2) start autocad, charge excel.lsp and start (getexcel)
3) to write in a cell: (wcells obsheet row column text)
4) to read a cell: (setq value (rcells obsheet column line))

n.b.: (getexcel) creates 2 public variables that refer to workbook (obxls) and related (obsheet)

bye
 

Attachments

hello and excuse if I answer now! I will try to do as you write even if I will surely find difficulties you know.... but cmq thank you! I thought instead to make a macro from excel to autocad or vice versa because in the end I have in autocad an attribute in which I insert the value of a cell of excel by copying it from excel and then move it in the autocad space according to the values x,y,z copied from excel.. .I thought it was possible to go macro
 
...I'm mistaken, too. .

command: (setq or (vlax-get-or-create-object "excel.application"))
; error: no function definition: vlax-get-or-create-object

vla and vlax putton on my knees... I don't understand them much. .
 
Now he took it...

(vl-load-com)
(setq or (vlax-get-or-create-object "excel.application"))

result
♪<vla-object 0000000029a861a8="" _application="">command: (print o)

♪<vla-object 0000000029a861a8="" _application=""> ♪<vla-object 0000000029a861a8="" _application="">But honestly, I don't know where I come like this. .define the variable "or" to which I attribute what gives me in response the vlax-get-or-create....but what would I be doing?
everything comes from creating the reference to the active excel file and worksheet to go to read, copy the values of the cells...but this step does not understand. .</vla-object></vla-object></vla-object>
 
I'm starting to figure something out. . .

; we open the excel file to ender it readable to the lisp instruction
; the file must be taxally prepared and saved in "c:\users\\\\\\\\\\desktop\\\\\\" after change of address in the lisp
; and always with the name bom.xls


(defun open ()
(startapp "c:\\program files\\\microsoft office 15\\root\\\office15\\excel.exe" "c:\\users\\\lorenzo\desktop\\\\lisp\bom.xls")
)

; creates reference to excel obxls file (open active sheet) and obsheet (active worksheet)
(defun getexcel ()
(vl-load-com) ; with this all vl-vla-vlax are loaded so that they are always ready
(setq obxls (vlax-get-or-create-object "excel.application")); I create the connection to the open excel
(vla-put-visible obxls t)

(setq obsheet (vlax-get-property obxls "cells")); I create the connection to the cell property of the active sheet
(setq rng (vlax-get-property obsheet 'range cell)); I put myself in the search cell - "cell is a veriable external string to function"
(setq val (vlax-get rng 'value)); I find the cell value
(princ val) ; I write on the prompt the value found
;(seq b "a")
;(seq value (rcells obsheet 1 b)
;(print value)
)

now launching (open) and (getexcel) open the file concerned and I can read and attribute the variable value of the first cell.
without you, I'm coming here! for now I had studied simpler things, but as you say... Meanwhile I started studying. .because rightly it would be too convenient to ask and receive...and then it is also intersecting. ..I think that now I will put this in cycle for when I have completed the whole action. Now I have to assign it to an attribute of a block....and I predict another scoglio. .
 
but why if I take a text and want to change its primary content using subst does not make me do it?

in the order I do: (Sectq text (entget))
send and select the text
then I do (assoc. 1 text)
and I get the text content regularly (1 . "pos.")
But if I do
(subst (1 "lore") (1 "pos.") text)
Does it work?

command: (subst (1 "a") (1 "pos.") text)
; error: wrong function: 1

Can no one tell me a reason?
 
Thanks gp as soon as I have the autocad underhand I try....I hope both for that damn apex... but at the same time I get the devil because if I write on the help of autocad or read in other sites that apex I did not see.
Let's say that if I insert the for cycle for the row variable that increases one until you find "mil" content on the first box I can store the coordinates that I have in three separate cells on the same row and the brand associated with the number of position of the element. with these variables stored now the problem is to take a block in which I have a "pos" attribute and insert the number of the stored variable, and then move this block to the coordinate identified by the other three variables. . .this to be done during the...
What do you think? Do you have any advice or other opinions?
 
you also omitted the point of the "pair bet" (dotted pair).
the apex, corresponding to the function (quote), returns the expision as it is, without evaluating it.

'(1 . "lore") -> (1 . "lore")


instead to build the list:

(cons 1 "lore") -> (1 . "lore")
 
Thank you gp in this end set I'm sorry and I'll let you know where I'm coming. for the moment I want to be able to automate the first essential phase of reading and storing only data related pos and coordinates the smart way for any number of rows with which the excel source file will be saved. next step will try this step for inserting into the attribute of the saved variable and then move it to the desired coordinates. Thanks again!!!
 
doing so I do not understand why it does not insert the text. .

command: (subst '(1 . "lore") '(1 . ") a)
; error: type of wrong subject: cons <nome 7f6dd17a2d0="" entità:=""></nome>
 

Forum statistics

Threads
44,997
Messages
339,767
Members
4
Latest member
ibt

Members online

No members online now.
Back
Top