How to create a LISP file for something already drawn in AutoCAD

How to create a LISP file for something already drawn in AutoCAD

jwjohnston9922
Explorer Explorer
1,442 Views
12 Replies
Message 1 of 13

How to create a LISP file for something already drawn in AutoCAD

jwjohnston9922
Explorer
Explorer

Hello,

I have a specific cabinet that I draw very often in AutoCAD and I would like to create an lsp file that can basically draw it for me. I just learned about LISP for the first time today so I don't know anything about it, but is it possible to get LISP code from my dwg? I guess in simplest terms, what comes first, the dwg or the lsp? Ideally I would like to be able to just draw something and then convert it to lsp, because I have no idea how to code. Let me know if this made sense!

 

Thank you,

James

0 Likes
Accepted solutions (1)
1,443 Views
12 Replies
Replies (12)
Message 2 of 13

pendean
Community Legend
Community Legend
Why not just make it into a BLOCK in a "library" folder then just INSERT it (or drag and drop it from a ToolPalette or ADCENTER) to reuse over and over again instead?

And if it have a few variations, why not just turn that into a Dynamic Block?

0 Likes
Message 3 of 13

jwjohnston9922
Explorer
Explorer

Thanks for the quick response pendean! I already use dynamic blocks, and they work really well, but I am thinking long term to create software and ai to automate a lot of what I do. This is just one of the many steps to achieve that! But I am definitely open to every idea out there. Would I be able to create a LISP code to automatically select specific dynamic blocks, or blocks in general?

0 Likes
Message 4 of 13

Moshe-A
Mentor
Mentor

@jwjohnston9922  hi,

 


@jwjohnston9922 wrote:

Hello,

I have a specific cabinet that I draw very often in AutoCAD and I would like to create an lsp file that can basically draw it for me. I just learned about LISP for the first time today so I don't know anything about it, but is it possible to get LISP code from my dwg? I guess in simplest terms, what comes first, the dwg or the lsp? Ideally I would like to be able to just draw something and then convert it to lsp, because I have no idea how to code. Let me know if this made sense!

 


AutoLISP still has no such capability, maybe in future who knows 🤣

to add to what @pendean said here is a great idea think about coping the cabinet. you can also use copy & paste from any open documents.

 

Moshe

 

 

0 Likes
Message 5 of 13

pendean
Community Legend
Community Legend
Accepted solution
LISP is like the tasks you do all day long manually, just quicker and if written well, also catch any gotchas in the process. So yes, LISP can do everything you want for drawing/inserting/selecting objects, but I'm not sure the ROI on writing a code to just draw a cabinet is worth it in the end since you're likely to always want to tweak it since none of us truly 100% recycle content for ever and ever and ever when it comes to cabinetry.
0 Likes
Message 6 of 13

jwjohnston9922
Explorer
Explorer

Ok great! Thank you @pendean @Moshe-A , I appreciate your answers! Since I just learned about LISP today I wanted to know the possibilities and limitations which were difficult to find by simply Googling. I may have been dreaming too much haha

 

Thank you!

James

0 Likes
Message 7 of 13

Moshe-A
Mentor
Mentor

W e l c o me  t o  A u t o L I S P  w o r l d  😀

0 Likes
Message 8 of 13

Sea-Haven
Mentor
Mentor

Yep a simple table.

SeaHaven_0-1690067922839.png

 

 

0 Likes
Message 9 of 13

john.uhden
Mentor
Mentor

@Sea-Haven ,

And just how are you attaching the legs to the top?  😟

I've built reproduction (colonial American) splayed/tapered leg tables and benches, but not without a skirt.

No, I will never attempt a Goddard-Townsend reproduction.

John F. Uhden

0 Likes
Message 10 of 13

Sea-Haven
Mentor
Mentor

Like the adds on TV that show the glue that will hold up a car its so strong only need a couple of drops. Don't forget what it does to your fingers.

0 Likes
Message 11 of 13

Sea-Haven
Mentor
Mentor

This is pop menu very easy to make can use Notepad. So pick your item then answer the lisp size questions.

SeaHaven_0-1690087687850.png

A multi story window panel dcl 1 others follow with further input.

SeaHaven_1-1690087743868.png

 

 

0 Likes
Message 12 of 13

jwjohnston9922
Explorer
Explorer

@Sea-Haven , How do you create a custom dialog box? I've been trying to find tutorials online but I can't find them anywhere!

0 Likes
Message 13 of 13

Sea-Haven
Mentor
Mentor

There is information in the HELP about making DCL's and how each type works radio buttons, edit boxes, toggles, listbox to mention a few.

 

If you do a dwg showing what you want then you may find some one will do a dcl for you so you can see how its made. I am playing with make simple dcl from Autocad objects. 

SeaHaven_1-1690157782923.png

 

Code generated

 

Testradio : dialog  { 
 label = "Please choose" ;
  : row  {
  : boxed_radio_column {
width = 20 ;
label = "Enter values" ;
	: radio_button	{
key = "Rb1";
label = "A";
}
spacer_1 ;
	: radio_button	{
key = "Rb2";
label = "B";
}
spacer_1 ;
	: radio_button	{
key = "Rb3";
label = "C";
}
spacer_1 ;
	: radio_button	{
key = "Rb4";
label = "D";
}
spacer_1 ;
spacer_1 ;
	ok_cancel ;
}
}
}

 

test code

(defun aaa ( / )
(setq dcl_id (load_dialog "D:\\acadtemp\\test2.dcl"))
(if (not (new_dialog "Testradio" dcl_id) )
(exit)
)
(action_tile "accept" "(done_dialog)")
(start_dialog)
(unload_dialog dcl_id)
)
(aaa)
0 Likes