cadmikee Posted June 1, 2019 Share Posted June 1, 2019 Hi. I have very limited knowledge of autolisp but I'm looking to create a lisp command to help me. I have drawings of offices with desks shown. I want to be able to draw a polyline around each desk plus an additional 800mm behind the desk. So imaging a desk 1600mm wide by 800mm deep showing on a 2d drawing with a chair behind. I need to draw a polyline around the desk plus an extra 800mm behind the desk. So in this example it would draw a 1600mm x 1600mm polyline on a specific layer. The desks may not always be horizontal and could be rotated to any angle. I was thinking if there was a way to pick the 4 corners of the desk and say the first pick is the back of the desk then somehow it could work out the additional 800mm and create the polyline. Has anyone come across something similar? Thanks all. Mike Quote Link to comment Share on other sites More sharing options...
marko_ribar Posted June 1, 2019 Share Posted June 1, 2019 There is nothing shown like you said... Upload a picture or sample DWG... It would be far more informative than text description... Quote Link to comment Share on other sites More sharing options...
cadmikee Posted June 1, 2019 Author Share Posted June 1, 2019 Hi, See attached an example (screen grab and DWG). The desks on the left are how they could be shown on the drawing and the desks on the right are how I need them polylined. Yes I can do each one separately and copy some but just interested to know if there was a routine that could do this... Thanks Mike polyline-desks.dwg Quote Link to comment Share on other sites More sharing options...
eldon Posted June 1, 2019 Share Posted June 1, 2019 Have you considered adding the polyline to the block of the desk? Quote Link to comment Share on other sites More sharing options...
cadmikee Posted June 1, 2019 Author Share Posted June 1, 2019 I have but the issue is most of the dwgs I have are fairly "dirty" and not all the desks are blocks, some are exploded or mirrored or were never blocks at all. Quote Link to comment Share on other sites More sharing options...
eldon Posted June 1, 2019 Share Posted June 1, 2019 I am not quite sure what you mean by "most of the drawings are dirty", but what a splendid opportunity you now have to make the drawings so much better! Quote Link to comment Share on other sites More sharing options...
devitg Posted June 2, 2019 Share Posted June 2, 2019 Please redifine the block as the desk is a polyline , as now it is made with lines and arcs , you also have the drawer and the chair . Made from lines and arcs Quote Link to comment Share on other sites More sharing options...
BIGAL Posted June 2, 2019 Share Posted June 2, 2019 Vl bounding box around block then make new box that is 800 mm offset in x as you want, probably need to do UCs for each block. pretty sure Lee-mac has bounding around objects. Version 2 like Eldon add the rectang to block definition and update the blocks. Put on "no plot layer". Quote Link to comment Share on other sites More sharing options...
BIGAL Posted June 2, 2019 Share Posted June 2, 2019 Had another go so much easier just did bedit and added the outline on another layer that was set to no plot all done. Quote Link to comment Share on other sites More sharing options...
devitg Posted June 2, 2019 Share Posted June 2, 2019 23 hours ago, cadmikee said: not all the desks are blocks, Quote Link to comment Share on other sites More sharing options...
cadmikee Posted June 2, 2019 Author Share Posted June 2, 2019 Thanks all. Not all the desks will be blocks. not to worry. I'll just work around it. Thanks Mike Quote Link to comment Share on other sites More sharing options...
ronjonp Posted June 3, 2019 Share Posted June 3, 2019 THIS should do what you want. 1 Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 3, 2019 Share Posted June 3, 2019 (edited) 2 hours ago, ronjonp said: THIS should do what you want. Thanks for the recommendation Ron - I even browsed this thread and hadn't considered using that program Edited June 3, 2019 by Lee Mac Quote Link to comment Share on other sites More sharing options...
devitg Posted June 3, 2019 Share Posted June 3, 2019 (edited) It did a minimum bouding box , but the OP ask it have to be 800 mm to the chair side . Edited June 3, 2019 by devitg Quote Link to comment Share on other sites More sharing options...
ronjonp Posted June 3, 2019 Share Posted June 3, 2019 52 minutes ago, Lee Mac said: Thanks for the recommendation Ron - I even browsed this thread and hadn't considered using that program I know it's not exactly what is needed but a good start Quote Link to comment Share on other sites More sharing options...
BIGAL Posted June 4, 2019 Share Posted June 4, 2019 I looked at the same and need to take the bounding box and only add the extra length in one direction. Because you have a min max pt its a bit messy and there are 4 solutions do a block name at a time would be a bit easier as it would apply to all named blocks say U D L R option. Need to do some sort of ucs identify as the dwg supplied if pick ucs ob for desk/chair its backwards so a extension would possibly go wrong way. Quote Link to comment Share on other sites More sharing options...
cadmikee Posted June 4, 2019 Author Share Posted June 4, 2019 Thanks all for your input. So I have had a think and thought I'd go back to basics and show my thoughts. I don't know about Autolisp programming although I have had some experience of PHP/basic so excuse my logic. So imagine a desk (or rectangle) on the screen. In its simplest form, is there a way to get the user to pick all 4 corners of the rectangle and store these co-ordinates in 4 separate variables, say P1, P2, P3 and P4. Then once we know these, and we make sure the user always starts at the front face of the desk and selects each corner in a clockwise fashion , can you add 800 to say the x co-ordinate of P3 and P4 (P3 = P3 + 800)??? and then pline between P1, P2, P3 and P4. Using some maths (<, > etc.) you can work out the orientation of the desk, for example, if the P1 x co-ordinate is > the P4 x co-ordinate, then the desk is facing right so you subtract 800 from the P1 and P2 co-ordinates. You could do the same with the y co-ordinates to work out if the desk is facing up or down. Would only work for horizontal or vertical desks but just a thought. Not sure if all that makes sense. So really as a starter for me, can you store each of the x,y,z co-ordinates in variables from a user picking points, do some maths on them and then connecting them up as a polyline? Thoughts??? Quote Link to comment Share on other sites More sharing options...
cadmikee Posted June 4, 2019 Author Share Posted June 4, 2019 So I have just managed to do what I wanted...well its a start. It only works with the desk shown in this orientation but I can now work on the maths formula etc. to move forward. Thanks for all your help. This is the code I made. It may not be 100% but it does what I want so far... (defun c:mike (/ p1 p2 p3 p4) (setq p1 (getpoint "\nfirst corner of rectangle: ")) (setq p2 (getpoint "\nSecond corner of rectangle: ")) (setq p3 (getpoint "\nThird corner of rectangle: ")) (setq p4 (getpoint "\nfourth corner of rectangle: ")) (setq x1 (car p1)) (setq y1 (cadr p1)) (setq z1 (caddr p1)) (setq x2 (car p2)) (setq y2 (cadr p2)) (setq z2 (caddr p2)) (setq newx1 (+ x1 800)) (setq newx2 (+ x2 800)) (setq newp1 (list newx1 y1 z1)) (setq newp2 (list newx2 y2 z2)) (command "pline" newp1 newp2 p3 p4 "c") (princ) ) Quote Link to comment Share on other sites More sharing options...
marko_ribar Posted June 4, 2019 Share Posted June 4, 2019 (edited) For any direction (orientation)... (defun c:mike ( / p1 p2 p3 p4 newp1 newp2 ) (setq p1 (getpoint "\nFirst corner of rectangle: ")) (setq p2 (getpoint "\nSecond corner of rectangle: ")) (setq p3 (getpoint "\nThird corner of rectangle: ")) (setq p4 (getpoint "\nFourth corner of rectangle: ")) (setq newp1 (polar p1 (angle p4 p1) 800.0)) (setq newp2 (polar p2 (angle p3 p2) 800.0)) (command "_.pline" "_non" newp1 "_non" newp2 "_non" p3 "_non" p4 "c") (princ) ) HTH., M.R. Edited June 4, 2019 by marko_ribar 1 Quote Link to comment Share on other sites More sharing options...
cadmikee Posted June 4, 2019 Author Share Posted June 4, 2019 Brilliant, thanks Marko. Thats perfect. 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.