Danial Posted April 21 Posted April 21 Is it possible that my whole drawing on autocad can be written into a lisp code in an easy way? Is there a way to convert dwg file into lsp? I really dont understand how to make the whole drawing with autolisp since i just want to type one command and the whole drawing appears. It may ask me for the arcs and the dimensions and when given with the provided information it can make the whole diagram. Please let me know a way or how i can do this. Quote
fuccaro Posted April 22 Posted April 22 Once you get the DWG, you can use ENTGET to transform an entity in a list of DXF codes. Yes, you could walk in the AutoCAD's database and transform the entities one by one. But probable you should include the nongraphic entities too. Say if a line must be placed on an inexistent layer, AutoCAD will create that layer "on the fly". But you must deal with text styles, dimstyles and so on. Also if there are inserts, you must define the blocks first. About the Xrefs -better don't even mention it. To make the long story short: in theory it's possible, for some drawings it is easier, for other ones is more complicated. 1 Quote
mhupp Posted April 22 Posted April 22 Cad's entmake lisp is probably the closest thing your going to get. you just select what you want and it will generate the entmake code. Why not have a template drawing or lee mac's Steal lisp with the steal all option? 1 Quote
CyberAngel Posted April 22 Posted April 22 Theoretically, you could generate a drawing with AutoLISP if you only needed to give it a few parameters. It's a little trickier if you don't have AutoCAD to tweak the finished product, but you can use TrueView to check your work. Without knowing more about the diagram you want to draw, we'd have trouble providing any more help than that. As mhupp suggests, it would be much easier to copy an existing drawing and modify it to suit your needs. Quote
Steven P Posted April 22 Posted April 22 (edited) Yes and no. The first screenshot is pure LISP / VLA- / program generated, the user gets the dialogue box to input the data, here an electrical single line diagram / one line diagram and depending on the inputs the diagram is drawn. Code for this including the dialogue is about 1600 lines, plus there is coding to create the blocks in the diagram. I made this up one Christmas break to amuse myself and see if it could work. It can work well if as below the drawings follow a standard layout, we can use rules to create what we need to do. Something like a building layout, a road or similar where we need to consider the interaction between what we are interested in and the rest of the world become a lot more tricky. Then drafting become more an art than a science. The no? No I can't share this. This mornings time filler was populating this, which uses the same blocks as above but with a nice dialogue interface - there are others out there too - each of these blocks are generated from code and the command is the text under the slide (example blkcb). The dialogue is about 600 lines and 2 lines of code for each entity in the blocks. My method here for coding all the blocks started with curiosity "minimum file size needed to draw something"... answer is via lisp file size is usually 50%+ of the dwg size. I put how many lines in there as an appreciation that it can be a lot of coding to draw something via LISP. Mine above are small databases for each entity, and these use 'entmake' to draw each part (or in the case of the SLD, some are generated on the fly), called each time you want to use them. Behind the lines there is code to generate layers, text styles and line types as required. Like MHUPPs link I have a small app that generates the code for each block when I want to add a new one to my database - makes things easier! So yes it is possible, there is quite a bit to it though. Edited April 22 by Steven P Quote
Steven P Posted April 22 Posted April 22 I don't know your LISP ability but maybe look at 'entmake', generate a small routine to draw basic entities to understand how that works, passing arguments to the function. For example (defun drawline (pt1 pt2 / result ) (setq result (entmakex (list '(0 . "LINE") ; entity type to make (cons 8 "0") ; layer (cons 10 pt1) ; start point (cons 11 pt2) ; end point ))) ; end list, entmakex, setq ) ; end defun is the basic code to draw a line from pt1 to pt2 - other entity types have different codes This can be called with something like: (drawline (getpoint "Select point 1") (getpoint "Select Point 2") ) Have a read, try to make up similar for other types and then all you need to do is draw the drawing! As a hint I would copy and paste polylines and splines off an internet search Quote
pkenewell Posted April 22 Posted April 22 Another Example: I wrote this back in the 90's (believe it or not) and still maintain it for drawing ANSI plug gages. It fully draws everything with Visual LISP. I Don't even use it anymore, but it's a good resource that I use as a test bed for trying out better code, and keeping myself exercised in LISP programming. 2 Quote
BIGAL Posted April 22 Posted April 22 We need a sample dwg or 2 -3 to make realistic comments. Like others have programs that draw objects like this house program but its like 100+ lisps so many different functions. 1 Quote
Steven P Posted April 23 Posted April 23 Your question has sparked some interest here, as Big Al asks, a few sample drawings and I am sure we can point you on your way or give you some code to use Last example for now, adding a legend to drawings (command line "BlkJW", all done via LISP): 1 Quote
BIGAL Posted April 23 Posted April 23 Whilst we wait for you Danial. Something like this. window frame.mp4 Quote
fuccaro Posted April 24 Posted April 24 Nice! Once I wrote a Lisp to draw and simulate the work of an Enigma machine. Unfortunately I can't make it work. It draws the machine on the screen, but when it comes to encrypt a text... well... it works only on my computer -from others I got only bug reports Anyway, that's an other example when there is nothing on the screen, the user starts a lisp and it makes the job. Quote
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.