itacad Posted October 7, 2018 Share Posted October 7, 2018 Hello, I was looking for a lisp to quickly draw an arrow...I found one but it asks too much information before starting ... To give an example I really like how to draw an arrow in the windows Paint program, where it is sufficient to indicate two vertices of a rectangle and the arrow drawn is proportional to the rectangle. I therefore thought to ask you this question: Is it possible to draw a polyline using relative points of an object? the relative points would be the object snap of a rectangle. In the example file that I enclose, I can draw a polyline inside a rectangle using its relative points, I would like to do it automatically. Greetings ARROW IN THE RECTANGLE.dwg Quote Link to comment Share on other sites More sharing options...
BIGAL Posted October 8, 2018 Share Posted October 8, 2018 (edited) Create a block and just change x & y scale or make it dynamic. Start with a 2x1 rectang. Edited October 8, 2018 by BIGAL Quote Link to comment Share on other sites More sharing options...
ronjonp Posted October 8, 2018 Share Posted October 8, 2018 (edited) Using BIGAL's idea .. this should work: (defun c:foo (/ a b c) ;; RJP » 2018-10-09 (cond ((and ;; Duh :) (setq a (getpoint "\nSpecify first corner point: ")) ;; Duh :) (setq b (getcorner a "\nSpecify other corner point: ")) ;; Get width and height ( subtract x's & y's ) (setq c (mapcar 'abs (mapcar '- a b))) ) ;; If the block arrow definition does not exist in drawing make it ( look into entmake ) (cond ((null (tblobjname "block" "PaintArrow")) (entmake '((0 . "BLOCK") (100 . "AcDbEntity") (67 . 0) (8 . "0") (100 . "AcDbBlockReference") (2 . "PaintArrow") (10 0 0 0) (70 . 0) ) ) (entmake '((0 . "LWPOLYLINE") (100 . "AcDbEntity") (67 . 0) (8 . "0") (100 . "AcDbPolyline") (90 . 9) (70 . 1) (43 . 0) (38 . 0) (39 . 0) (10 1 0) (10 0 -0.5) (10 0 -0.25) (10 -1 -0.25) (10 -1 0.25) (10 0 0.25) (10 0 0.5) (10 1 0) (10 0 0.5) ) ) (entmake '((0 . "ENDBLK") (100 . "AcDbBlockEnd") (8 . "0"))) ) ) ;; Insert the block (entmakex (list '(0 . "INSERT") '(100 . "AcDbEntity") '(8 . "PaintArrow") '(100 . "AcDbBlockReference") '(2 . "PaintArrow") ;; Mid point between point 'a' & 'b' ( insertion point of block ) (cons 10 (polar a (angle a b) (/ (distance a b) 2.))) ;; X scale / 2. (cons 41 (/ (car c) 2.)) ;; Y scale (cons 42 (cadr c)) '(43 . 1.0) '(50 . 0.0) ) ) ) ) (princ) ) Edited October 9, 2018 by ronjonp * added arrow direction from pick points, added some comments Quote Link to comment Share on other sites More sharing options...
itacad Posted October 8, 2018 Author Share Posted October 8, 2018 ... wow! ...just what I wanted! please you could insert lines of comment and a little explanations? I don't understand how the lisp works and I'd like to try to prepare more drawings besides the arrow and more arrows. Finally a suggestion, a request, a whim ...since it is an arrow, would it be possible to make four variations and decide the orientation of the arrow by using the arrow key or the arrow on the numeric keypad? thank you Quote Link to comment Share on other sites More sharing options...
BIGAL Posted October 9, 2018 Share Posted October 9, 2018 (edited) A simple radio button dcl would be a good idea with 4 buttons. Just need some time. Grr ? Re code above Google DXF codes or in the help dxf codes, as few quick ones 8 = layer, 2 =block name, 0 = object type, 10 is a point like start point, 11 is end point etc. Edited October 9, 2018 by BIGAL Quote Link to comment Share on other sites More sharing options...
ronjonp Posted October 9, 2018 Share Posted October 9, 2018 17 hours ago, itacad said: ... wow! ...just what I wanted! please you could insert lines of comment and a little explanations? I don't understand how the lisp works and I'd like to try to prepare more drawings besides the arrow and more arrows. Finally a suggestion, a request, a whim ...since it is an arrow, would it be possible to make four variations and decide the orientation of the arrow by using the arrow key or the arrow on the numeric keypad? thank you I added some comments to the code above. Sorry don't have time to add options. Quote Link to comment Share on other sites More sharing options...
itacad Posted October 9, 2018 Author Share Posted October 9, 2018 ok, thanks for the lisp and for the explanation! Quote Link to comment Share on other sites More sharing options...
itacad Posted October 18, 2018 Author Share Posted October 18, 2018 Hello! I modified the lisp slightly so that I have one for each direction of the arrow, but I have this question: 1) is it possible to draw the arrow on the layer 0? (I did not have time to try to see which line was to be modified for this) 2) is it possible to explode the arrow with the lisp after it has been drawn? 3) with the lisp in vertical direction, proportions respect to the source rectangle are not respected, how to correct to solve this problem? 4) would it be possible to make a single lisp that has the arrow direction as an input using the arrow keys or number keys 2 4 6 8? regards arrow.zip Quote Link to comment Share on other sites More sharing options...
BIGAL Posted October 19, 2018 Share Posted October 19, 2018 With regards to explode it. Would make sense just draw a pline dont make it a block. You can still rotate the pline around some known point. Can you clarify need it as a block or as a pline ? Quote Link to comment Share on other sites More sharing options...
ronjonp Posted October 19, 2018 Share Posted October 19, 2018 (edited) (defun c:foo (/ a b c d) ;; RJP » 2018-10-09 (cond ((and ;; Duh :) (setq a (getpoint "\nSpecify first corner point: ")) ;; Duh :) (setq b (getcorner a "\nSpecify other corner point: ")) ;; Get width and height ( subtract x's & y's ) (setq c (mapcar 'abs (mapcar '- a b))) ) ;; If the block arrow definition does not exist in drawing make it ( look into entmake ) (cond ((null (tblobjname "block" "PaintArrow")) (entmake '((0 . "BLOCK") (100 . "AcDbEntity") (67 . 0) (8 . "0") (100 . "AcDbBlockReference") (2 . "PaintArrow") (10 0 0 0) (70 . 0) ) ) (entmake '((0 . "LWPOLYLINE") (100 . "AcDbEntity") (67 . 0) (8 . "0") (100 . "AcDbPolyline") (90 . 9) (70 . 1) (43 . 0) (38 . 0) (39 . 0) (10 1 0) (10 0 -0.5) (10 0 -0.25) (10 -1 -0.25) (10 -1 0.25) (10 0 0.25) (10 0 0.5) (10 1 0) (10 0 0.5) ) ) (entmake '((0 . "ENDBLK") (100 . "AcDbBlockEnd") (8 . "0"))) ) ) ;; Insert the block (cond ((setq d (entmakex (list '(0 . "INSERT") '(100 . "AcDbEntity") ;; Here is the layer it gets inserted on ;; but since you explode it does not matter '(8 . "PaintArrow") '(100 . "AcDbBlockReference") '(2 . "PaintArrow") ;; Mid point between point 'a' & 'b' ( insertion point of block ) (cons 10 (polar a (angle a b) (/ (distance a b) 2.))) ;; X scale / 2. (cons 41 (/ (car c) 2.)) ;; Y scale (cons 42 (cadr c)) '(43 . 1.0) '(50 . 0.0) ) ) ) (setq d (vlax-ename->vla-object d)) (while (getpoint "\nPick point to flip rotation: ") (vla-put-rotation d (+ (/ pi 2.) (vla-get-rotation d))) (vla-update d) ) ;; Why explode ? (vla-explode d) (vla-delete d) ) ) ) ) (princ) ) Edited October 19, 2018 by ronjonp Quote Link to comment Share on other sites More sharing options...
itacad Posted October 23, 2018 Author Share Posted October 23, 2018 Hello, thank you very much...Nice way to direct the arrow!!! The explanation for the explode is that if I copy drawing pieces from one file to another where the paintarrow block is already defined, it is resized...it would be enough for me to have exploded the block, but not the polyline that forms the block as in the last version. For the layer question, which lines must be corrected for draw the polyline on the layer 0 (my problem is that the block and the layer have the same name "Paintarrow" so I have to do a lot of combination to find out how to make the correction. Greetings and thanks again Quote Link to comment Share on other sites More sharing options...
ronjonp Posted October 24, 2018 Share Posted October 24, 2018 17 hours ago, itacad said: Hello, thank you very much...Nice way to direct the arrow!!! The explanation for the explode is that if I copy drawing pieces from one file to another where the paintarrow block is already defined, it is resized...it would be enough for me to have exploded the block, but not the polyline that forms the block as in the last version. For the layer question, which lines must be corrected for draw the polyline on the layer 0 (my problem is that the block and the layer have the same name "Paintarrow" so I have to do a lot of combination to find out how to make the correction. Greetings and thanks again I cannot replicate the resizing of the block when pasting into a drawing? Also, look at the comments in the code above .. it gives you direction on the layering. Quote Link to comment Share on other sites More sharing options...
itacad Posted October 28, 2018 Author Share Posted October 28, 2018 I will try to interpret the lisp as you suggest...In the meantime, because in theme with the discussion, I take the liberty of reporting a lisp of Lee Mac that serves to draw stars http://lee-mac.com/star.html I will try to understand this too 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.