CadFrank Posted July 22, 2011 Share Posted July 22, 2011 Hi to all, I am new at lisp and i would like to kno how create box and inserte a block in it. for exemple a 2 x 4 stud and on top or it a of a 2 x 4 Quote Link to comment Share on other sites More sharing options...
Tharwat Posted July 22, 2011 Share Posted July 22, 2011 (edited) What is the name of your block and where are you going to insert it ( insertion point ) ? Edited July 22, 2011 by Tharwat words correction Quote Link to comment Share on other sites More sharing options...
CadFrank Posted July 22, 2011 Author Share Posted July 22, 2011 The name of my block could be 2" x 4" and it will be located at the top of my rectangle Quote Link to comment Share on other sites More sharing options...
Tharwat Posted July 22, 2011 Share Posted July 22, 2011 The name of you block is not correct and it can not be named with quotation marks at all . Quote Link to comment Share on other sites More sharing options...
CadFrank Posted July 22, 2011 Author Share Posted July 22, 2011 Oh sry just name it 123 Quote Link to comment Share on other sites More sharing options...
CadFrank Posted July 23, 2011 Author Share Posted July 23, 2011 Hi, well this is simple for some people but im new at autolisp. I would need to create a lisp for the image ill be showing you. i can create a lisp to make a box but i can't inserte the block in it. so if some1 can help me figure out the rest i would be gratefull. thank you! Quote Link to comment Share on other sites More sharing options...
paulmcz Posted July 23, 2011 Share Posted July 23, 2011 Does the block already exist? How does it look like? Where is the block you need to insert now? In the drawing? Is it a separate file? Where is the block's base point, in relation to the block's geometry? Quote Link to comment Share on other sites More sharing options...
CadFrank Posted July 23, 2011 Author Share Posted July 23, 2011 Well it is at the same place as the getpoint 2 and the block already exist Quote Link to comment Share on other sites More sharing options...
paulmcz Posted July 23, 2011 Share Posted July 23, 2011 Is the block in the drawing? Is it a separate file? Post the picture of the block, show the exact location of the base point and dimension it in detail. Or better yet, attach the block's drawing (dwg) Quote Link to comment Share on other sites More sharing options...
CadFrank Posted July 23, 2011 Author Share Posted July 23, 2011 Well i dont have the block with me but if you give me the code i need i could fill in the blanks after unless you really need the block Quote Link to comment Share on other sites More sharing options...
CadFrank Posted July 23, 2011 Author Share Posted July 23, 2011 here is the block with demension Quote Link to comment Share on other sites More sharing options...
paulmcz Posted July 23, 2011 Share Posted July 23, 2011 Since nobody knows the dimensions of your block, following code is good for inserting first of your blocks. For the second one, you need to calculate location of the second insertion point. (command "_.insert" "path or block's name" point2 "x-scale" "y-scale" "rotation") If the block is already in the drawing, skip the path Quote Link to comment Share on other sites More sharing options...
paulmcz Posted July 23, 2011 Share Posted July 23, 2011 (edited) OK, the second block will have to have the insertion point = p3 => (setq p3 (polar point2 (* pi 1.5) 38.0)) Edited July 23, 2011 by paulmcz Quote Link to comment Share on other sites More sharing options...
CadFrank Posted July 23, 2011 Author Share Posted July 23, 2011 So lets say this is the code i started [font=Courier New](defun c:BOX ( / pt1 pt2 pt3 pt4 )(setq pt1 (getpoint "Pick first corner: "))(setq pt3 (getcorner pt1 "Pick opposite corner: "))(setq pt2 (list (car pt3) (cadr pt1)))(setq pt4 (list (car pt1) (cadr pt3)))(command "line" pt1 pt2 pt3 pt4 "c" )[/font](command "_.insert" "path or block's name" point2 "x-scale" "y-scale" "rotation")(setq p3 (polar point2 (* pi 1.5) 38.0)))) would this be ok! Quote Link to comment Share on other sites More sharing options...
paulmcz Posted July 23, 2011 Share Posted July 23, 2011 (edited) This would do it, if the block's name is "123", it resides in the drawing and you want to accept x-scale as 1.0, y-scale as 1.0 and rotation as 0.0. (defun c:BOXX (/ osn pt1 pt2 p3) (setq osn (getvar "osmode")) (setvar "osmode" 0) (setq pt1 (getpoint "Pick first corner: ")) (setq pt2 (getcorner pt1 "Pick opposite corner: ")) (command "rectang" pt1 pt2) (command "_.insert" "123" pt2 "" "" "" ) (setq p3 (polar pt2 (* pi 1.5) 38.0)) (command "_.insert" "123" p3 "" "" "") (setvar "osmode" osn) (princ) ) Edited July 28, 2011 by paulmcz Quote Link to comment Share on other sites More sharing options...
paulmcz Posted July 23, 2011 Share Posted July 23, 2011 The "BOX" is the autocad's command, so you can't use it as a defun's call code! Quote Link to comment Share on other sites More sharing options...
irneb Posted July 23, 2011 Share Posted July 23, 2011 Could you perhaps make a sample drawing and attach it here so we can see what it needs? Quote Link to comment Share on other sites More sharing options...
Tharwat Posted July 23, 2011 Share Posted July 23, 2011 Could you perhaps make a sample drawing and attach it here so we can see what it needs? They have repeated the same request in two different threads , check it out . http://www.cadtutor.net/forum/showthread.php?61231-Creating-a-lisp-help-needed&p=415942&viewfull=1#post415942 Quote Link to comment Share on other sites More sharing options...
CadFrank Posted July 23, 2011 Author Share Posted July 23, 2011 Well thank you it works.! Quote Link to comment Share on other sites More sharing options...
SLW210 Posted July 25, 2011 Share Posted July 25, 2011 I have merged your threads. Please you only need one thread per question. Creating Multiple threads only confuses. 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.