nasper Posted October 18, 2023 Posted October 18, 2023 Hello everyone. I hope you are all well. I have a small request to make. I'm in need of a custom AutoCAD routine that will create polyline blocks based on user input, which will be received three times. For example, if the user enters 20, 10, and 0, the routine should generate a polyline with a length of 20, a starting width of 10, and an ending width of 0. The user should also be able to specify a name, and this name will be used to create a block. Is it possible to create such a routine? I know it may sound a bit basic, but I would greatly appreciate your assistance with this. Quote
BIGAL Posted October 19, 2023 Posted October 19, 2023 (edited) Just write down what you do manually that is the lisp steps. Good task to start to learn simple lisp coding. Make the 1st point at 0,0,0 Use (setq pt1 '(0 0 0)) (setq pt2 (list (getreal "\nEnter length ") 0 0)) pline Select start of polyline or [Follow] <Last point>:pt1 (0 0 0) Select start of polyline or [Follow] <Last point>: Set next point or [draw Arcs/Distance/Follow/Halfwidth/Width]:w Starting width <0>: 10 Ending width <10>: 0 Set next point or [draw Arcs/Distance/Follow/Halfwidth/Width]:pt2 (20.0 0 0) Set next point or [draw Arcs/Distance/Follow/Halfwidth/Width]: Set next point or [draw Arcs/Distance/Follow/Halfwidth/Width/Undo]: Convert above to lisp, then make block. (command "block" (getstring "\nEnter block name") '(0 0 0) (entlast) "") Please have a go plenty here will help. Edited October 19, 2023 by BIGAL 1 Quote
nasper Posted October 19, 2023 Author Posted October 19, 2023 Thank you so much for your help and for sharing the code with me. I truly appreciate your support and guidance. I'm excited to dive into my studies with the code you provided. Your assistance means a lot to me, and I'm grateful for the opportunity to learn from your expertise. Once again, thank you for your kindness and generosity. Quote
exceed Posted October 19, 2023 Posted October 19, 2023 excluding the issue of whether it is inefficient to create polylines with two nodes one by one as blocks (if you simply want to name individual polylines, it is recommended to use xdata or hyperlinks). To do what you want, 1. create a command with defun, 2. receive the value with (getreal) or (getint), and receive the name with (getstring). 3. You can create a polyline with (entmake). In order to do entmake, there must be a dxf list required for entmake, and polyline information is included here. To find out the value easily, you can create a polyline once and then "dump" it to see the code. dump - https://www.cadtutor.net/forum/topic/74613-dxf-fields/?do=findComment&comment=590936 Not all dxf codes are required, but there are essential items for each entity. http://docs.autodesk.com/ACD/2011/ENU/filesDXF/WS1a9193826455f5ff18cb41610ec0a2e719-79fc.htm 4. And to make this polyline into a block, you need to add entmake for blocks before and after the polyline entmake statement. And since it is a block, it must be entered as insert to be created in the drawing. 5. To make it easier to specify the reference point, when creating a block, it is recommended to create the starting point based on 0,0. 6. If you want to insert without using command, you can use vla-insertblock. 1 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.