Jump to content

Polyline with offset


cadmikee

Recommended Posts

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

Link to comment
Share on other sites

There is nothing shown like you said... Upload a picture or sample DWG... It would be far more informative than text description...

Link to comment
Share on other sites

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.JPG

polyline-desks.dwg

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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".

Link to comment
Share on other sites

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 by Lee Mac
Link to comment
Share on other sites

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 :) 

Link to comment
Share on other sites

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. 

Link to comment
Share on other sites

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???

Link to comment
Share on other sites

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)
)

 

 

lisp.JPG

Link to comment
Share on other sites

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 by marko_ribar
  • Like 1
Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...