assumbi3 Posted August 7, 2015 Share Posted August 7, 2015 Hi All, I'm new in VBA and I need your help writing a code for my project. In my drawing there are lots of circle with different diameter and different locations. I need them to put on Excel tabulated. For now I’m just using the Coordinate lisp and manually put to Excel the coordinate and the radius. Thank you in advance and really appreciate your help. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted August 8, 2015 Share Posted August 8, 2015 1st step go to VLISP you will get much more help VBA is officially unsupported but still works, download GETEXCEL.lsp this has all the code examples you will need for to and from excel. Use dumpit and pick a circle etc you will see all the values you can simply get at. ;;; Dump all methods and properties for selected objects ; ;;;===================================================================; ;;; DumpIt ; ;;;-------------------------------------------------------------------; ;;;===================================================================; (defun C:DumpIt ( / ent) (while (setq ent (entsel)) (vlax-Dump-Object (vlax-Ename->Vla-Object (car ent)) T ) ) (princ) ) An example (setq obj (vlax-Ename->Vla-Object (car (entsel "pick circle")))) (setq cenpt (vlax-safearray->list (vlax-variant-value (vla-get-center obj)))) (alert (strcat "Area= " (rtos (vla-get-area obj) 2 1) "\nCentre point X=" (rtos (nth 0 cenpt) 2 2) " Y=" (rtos (nth 1 cenpt) 2 2) " Z=" (rtos (nth 2 cenpt)) "\nDiameter " (rtos (vla-get-diameter obj) 2 2) )) Quote Link to comment Share on other sites More sharing options...
assumbi3 Posted August 8, 2015 Author Share Posted August 8, 2015 Bigal, Sir, thank you for the quick reply...Actually I never wrote a code on LISP I use only VBA, but I try to manage to run the first code you gave, it was fine...but the second code, I don't know how, I try to put after the fist code the result has an error...anyway I'll try my best to learn more on this LISP...Can you give me some name of good reference books. Regarding that GETEXCEL.lsp you said, I'll copy that code and study because really totally different from VBA codes. Thanks, Quote Link to comment Share on other sites More sharing options...
BIGAL Posted August 9, 2015 Share Posted August 9, 2015 (edited) Copy the code to notepad and save it as say Circdetail.lsp then save and use Appload to load it. Same with DUMPIT.lsp only difference is its a defun so after appload you need to type dumpit to run. I have changed the post so the circle detail is a defun also but you call it from another part of your circle program. (defun circdetail ( / obj n cenpt) (setq ss (ssget "X" (list (cons 0 "Circle")))) (setq n (sslength ss)) (setq x n) (repeat n (setq en1 (ssname ss (setq x (- x 1)))) (setq obj (vlax-Ename->Vla-Object en1)) (setq cenpt (vlax-safearray->list (vlax-variant-value (vla-get-center obj)))) ; this where you would save all the answers so write to excel or return back to master program (alert (strcat "Area= " (rtos (vla-get-area obj) 2 1) "\nCentre point X=" (rtos (nth 0 cenpt) 2 2) " Y=" (rtos (nth 1 cenpt) 2 2) " Z=" (rtos (nth 2 cenpt)) "\nDiameter " (rtos (vla-get-diameter obj) 2 2) )) ) ) (circdetail); needed so it will run Edited August 10, 2015 by BIGAL Quote Link to comment Share on other sites More sharing options...
assumbi3 Posted August 9, 2015 Author Share Posted August 9, 2015 Sir, this is awesome. Thank you… I’ll try this on Monday in my office and I’ll comeback to you. Many thanks... Quote Link to comment Share on other sites More sharing options...
assumbi3 Posted August 10, 2015 Author Share Posted August 10, 2015 Sir, I try the LISP you gave, at fist it doesn't work because the drawing is 3D object, but I manage to work it out by Exploding, Flatten and Overkill the drawing. Attached link below is the sample of the drawing (FYI only). https://www.dropbox.com/s/4n4ecegjglioup5/SidePanel.dwg?dl=0 Thank you so much and more power. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted August 11, 2015 Share Posted August 11, 2015 Maybe look at the way you start the part if you were use some fields for the x y & rad as you make the circles these could be on a different layer when you extrude the circles, the text will remain it would then be pretty simple to find this text and thats your list of all circle detail, and you still have a 3d part. Quote Link to comment Share on other sites More sharing options...
RICVBA Posted August 11, 2015 Share Posted August 11, 2015 @assumbi3 should you not succeed with the lisp way, I could try and help you with VBA. and, in this case, I'd need some more details to start from: - a ready-to use dwg file example - not to explode, flatten and whatever - an excel file example Quote Link to comment Share on other sites More sharing options...
BIGAL Posted August 11, 2015 Share Posted August 11, 2015 The question RICVBA is how do you get the properties of a 3D object, start with a simple rectang extruded and with 1 round hole subtracted need, centre pt and radius of hole. Really the question is not VBA or lisp but rather what methods are available to work out a solid 's properties. The help files will give equivalent VBA to most of the vl that I have used. Hopefully someone out there knows how to pull apart a 3d object. Quote Link to comment Share on other sites More sharing options...
RICVBA Posted August 11, 2015 Share Posted August 11, 2015 The question RICVBA is how do you get the properties of a 3D object, start with a simple rectang extruded and with 1 round hole subtracted need, centre pt and radius of hole. Really the question is not VBA or lisp but rather what methods are available to work out a solid 's properties. The help files will give equivalent VBA to most of the vl that I have used. Hopefully someone out there knows how to pull apart a 3d object. I agree that's why I could only offer help starting from "a ready-to use dwg file" which assumbi3's first post description seemed to guarantee. managing 3D objects is quite tough a work, at least for my knowledge. I think you must be allowed to make assumptions (deal with cylinders only, all of them are properly oriented,...) in order to start thinking about a useful routine I believed NET could offer more control over this issue, but I'm not that sure right now. Quote Link to comment Share on other sites More sharing options...
assumbi3 Posted September 23, 2015 Author Share Posted September 23, 2015 Hi Bigal and Ricvba, Sorry, I was on vacation to my country home town last month. No internet connection out there. Anyway here are my concerns. First of all, I’m working on wood work factory here in Kuwait, we are using IMOS Cad software, it is an Autocad base software, it is use for customized cabinetry and our CNC machine is not compatible with this software because the machine was old and our work here will double which we create first IMOS Cad and transfer the drawing to CNC operator with that Coordinate Lisp tags on it and then they will redraw again in AlphaCAM software by then finally to the machine. Actually the IMOS Cad has an additional plugins called IMOS CAM which will link to latest CNC machines, because of our old machine I’m planning to make a 3rd party software that when I select the object in the Autocad (i.e. Circle) it will give me the entities like the coordinate, radius and with the depth the better, but now I understand that it is too difficult to get the depth. I was planned before to make the result to Excel because I already done the source code of converting to CNC machine by using the visual basic of Excel and by manually encoding the entities which is more vulnerable to human error. I really appreciate your help. Thank you once again. Amado Quote Link to comment Share on other sites More sharing options...
RICVBA Posted September 24, 2015 Share Posted September 24, 2015 as for me, I can only give some contribution with Excel and Autocad if that is your background also, then I'd ask you to attach a simple but detailed "example" of what your input and output should look like and work for instance: - an autocad file where to select objects - an Excel file where to show object's info in bye Quote Link to comment Share on other sites More sharing options...
assumbi3 Posted September 24, 2015 Author Share Posted September 24, 2015 Hi Sir, Thank you for your quick reply. Attached below is a dropbox link for the four files. https://www.dropbox.com/sh/54e7clw5gzqq2dd/AAApNNJ87iIk3_rC0I2Ri0NLa?dl=0 And as follows: 1) The Autocad File – which is extracted side panel from the cabinet created from IMOS. Which has a holes and a groove. 2) Excel file – where I encode the entities and then run the VBA of excel then I copy the result in textbox then paste on notepad and save as .FXM file extension then this file will be read through our CNC machine software. 3) FXM file – file that can be read by our CNC software and converted to G codes and M codes for the machine (result is .ANC file). 4) ANC file – is the source code for our CNC machine. Just tell me if you need more information or more files. Actually I need only from you is that selecting from AutoCad to Excel. Thank you in advance. Regards, Amado Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.