Dr.Lube
Guest
Hello everyone,
I try to be more exhaustive since in the title I can only use tot letters (and I used them all!)
for work I need to automate the calculation of the center of stiffness.
what I do is convert to polyline regions and go to extract the coordinates of the center and the main moments of inertia. everything is put on a support excel file where I will perform the necessary calculations to find the coordinates of the inertia center that I will then insert, as a point, inside autocad.
to make this use two lisp, that of data extraction is made by me and while that of export and forwarding data from excel I found it on the net.
the problem I have encountered is the inability to make a cycle with progressive index so as to move inside the excel file. in the import in fact I always overwrite the same line! another problem is that the values are imported to me with the point, instead of with the comma.
missing the part where I take the processed data, but I stepped by step
the question is therefore: how do I move forward?
below the code for the use of excel (Annex)
Thanks
dennis
I try to be more exhaustive since in the title I can only use tot letters (and I used them all!)
for work I need to automate the calculation of the center of stiffness.
what I do is convert to polyline regions and go to extract the coordinates of the center and the main moments of inertia. everything is put on a support excel file where I will perform the necessary calculations to find the coordinates of the inertia center that I will then insert, as a point, inside autocad.
to make this use two lisp, that of data extraction is made by me and while that of export and forwarding data from excel I found it on the net.
the problem I have encountered is the inability to make a cycle with progressive index so as to move inside the excel file. in the import in fact I always overwrite the same line! another problem is that the values are imported to me with the point, instead of with the comma.
Code:
(vl-load-com)
(defun c:inerzia ( / acapp ent i xy ix iy x y)
(setq acapp (vlax-get-acad-object))
(set indexq 1)
(sing)
(Sectq ent (car(entsel)));
(setq ent (vlax-ename->vla-object ent));
(setq xy (vla-get-centroid ent)
(Sectq i (vla-get-principalmoments ent));
(setq ix (vlax-safearray-get-element (vlax-variant-value i) 0) ; variant is an array of 2 elements, extract the first ix
(setq iy (vlax-safearray-get-element (vlax-variant-value i)); see above, I extract the second iy
(setq x (vlax-safearray-get-element (vlax-variant-value xy) 0) ;coordinated center x
(setq y (vlax-safearray-get-element (vlax-variant-value xy) 1) ;coordinated y
;the idea now was to create an array that contains all the data of the while cycle. here is definitely wrong, it is saved at the last attempt I made to understand how it worked
(setq cord (vlax-make-safearray vlax-vbdouble '(1 . 3)))
(vlax-safearray-put-element cord 0 index ix)
; below is how I did it at first, without extracting data individually. . I had 2 lists that if inserted in exel were important "correct" in 4 columns
(setq i (vlax-safearray->list (vlax-variant-value i)))
(setq xy (vlax-safearray->list (vlax-variant-value xy))
; export of lists
(setq xl (vlax-get-or-create-object "excel.application"))
(openexcel "c:\\prova.xls" nil)
;apro the test.xls file located in that path, on the page "inertia" and with nil I do not see it appear in the taskbar
(putcell "a1" xy) ; insert in the cell
(putcell c1 i)
(closeexcel "c:\\prova.xls")
(setq index (1+ index)); increase the row counter
);
(princ)
); end
the question is therefore: how do I move forward?
below the code for the use of excel (Annex)
Thanks
dennis