Jump to content

Lisp to turn a two line pollylines into a rectangle.


Recommended Posts

Posted

Don't know if this is actually possible or not but I'm trying to come up with a way to automatically turn a two line pollylines into a rectangles. Using the long line as a baseline and the short line as an offset.  Anyone know of anything like this or how I'd even start on attempting it.

image (1).png

Posted

Just pick pline, if they are always 2 segments then get length of each segment the shorter defines the endpoint which is used in vlax-curve-getclosestpointto so can work out offset distance, then just do some polar calcs and draw a new rectang.

 

or

 

Pick an end on longer side this defines which end is to be called start and the other end. So again use getclosestpointto using correct point, when you use entsel you get a point so can compare distance pt-start pt-end and swap the start and end points for the calcs.

 

Posted
44 minutes ago, BIGAL said:

Just pick pline, if they are always 2 segments then get length of each segment the shorter defines the endpoint which is used in vlax-curve-getclosestpointto so can work out offset distance, then just do some polar calcs and draw a new rectang.

 

 

Think this makes sense in theory to me but I'm afraid I wouldn't know where to begin with coding this.  Also I'm guessing you'd have to use it one at a time rather than selecting multiple plines at once?

 

Posted
2 hours ago, troggarf said:

Try Lee-Mac's 3-Point rectangle:

http://lee-mac.com/3pointrectangle.html

 

First along the long edge and then the shorter one...

This is what I've been using up to now actually.  It's really good but I'm just wondering if it's possible to further automate it if I have hundreds to draw. 

Posted
11 hours ago, Jamesclark64 said:

This is what I've been using up to now actually.  It's really good but I'm just wondering if it's possible to further automate it if I have hundreds to draw. 

@Jamesclark64, please upload a sample dwg.

 

Posted
18 minutes ago, Jamesclark64 said:

Here's two examples one vertical and one diagonal. 

@Jamesclark64image.png.9f0be614d9fa6d1de35f909d234c0407.png, but you ask for 2 side polys, no for 2 polys side

Posted
17 minutes ago, devitg said:

@Jamesclark64image.png.9f0be614d9fa6d1de35f909d234c0407.png, but you ask for 2 side polys, no for 2 polys side

Sorry I don't think I worded my original post well. Its essentially a polly made from two separate lines. The longer of the two lines is the baseline and the end of the short line is the extent of the offset. 

Posted
52 minutes ago, Jamesclark64 said:

polly made from two separate lines

@James   , so

There are 2 polys ,  in contact at a common point, but not a polys with 3 vertex.

 

Please upload a sample.dwg with such condition 

 

Posted
1 hour ago, devitg said:

@James   , so

There are 2 polys ,  in contact at a common point, but not a polys with 3 vertex.

 

Please upload a sample.dwg with such condition 

 

I'm such an idiot.  Must have exploded it before uploading.  Please try this one. 

example2.dwg

Posted (edited)
;|===========================================================================|
 |                                                                           |
 |___________________________________________________________________________|;
(defun c:BX (/ ss c say tek bx mnp mxp)
  (if (setq ss (ssget))
    (progn
      (setq c 0 say (sslength ss))
      (while (< c say)
(setq tek (ssname ss c)
      bx (vla-getboundingbox (vlax-ename->vla-object tek) 'mnp 'mxp)
      mnp (vlax-safearray->list mnp)
      mxp (vlax-safearray->list mxp))
  (command ".rectangle" "non" mnp "non" mxp)
(setq c (1+ c)))))(princ))

maybe it will work for you ,

 

Plines around the selected object

Edited by thecocuk07
Posted

thecocuk07 vla-getboundingbox it has the problem of always being in the X-Y plane so if a  pline is on an angle it will not work. Just test.

Posted
57 minutes ago, Jamesclark64 said:

This is fantastic! I can't thank you enough! Is there a way I can send you some dollars for a few beers?

 

@Jamesclark64

 is not my whole manufacture , LEE-MAC help a lot . 

Thanks for the beers , but sadly I live at the FAR SOUTH . Cordoba City  Argentina 

 

Córdoba -Argentina

Posted
17 hours ago, devitg said:

 

@Jamesclark64

 is not my whole manufacture , LEE-MAC help a lot . 

Thanks for the beers , but sadly I live at the FAR SOUTH . Cordoba City  Argentina 

 

Córdoba -Argentina

That Lee-mac routine is a lovely bit of bit of code, I used to have to trace over beams and joists on pointclouds and it made my life so much smoother. I hope Cordoba City is as lovely as it looks. Feel free to pm me a bitcoin address if you change your mind about thoes beers. Thanks again and take care. 

Posted
On 3/30/2023 at 9:47 AM, BIGAL said:

thecocuk07 vla-getboundingbox it has the problem of always being in the X-Y plane so if a  pline is on an angle it will not work. Just test.

@BIGALyou are right   ,,,  I missed this detail . thank u 

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