Jamesclark64 Posted March 28, 2023 Posted March 28, 2023 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. Quote
BIGAL Posted March 28, 2023 Posted March 28, 2023 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. Quote
Jamesclark64 Posted March 28, 2023 Author Posted March 28, 2023 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? Quote
troggarf Posted March 29, 2023 Posted March 29, 2023 Try Lee-Mac's 3-Point rectangle: http://lee-mac.com/3pointrectangle.html First along the long edge and then the shorter one... Quote
Jamesclark64 Posted March 29, 2023 Author Posted March 29, 2023 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. Quote
devitg Posted March 29, 2023 Posted March 29, 2023 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. Quote
troggarf Posted March 29, 2023 Posted March 29, 2023 Found this a long time ago on a Chinese LISP forum: MinAreaRectangle.lsp Quote
Jamesclark64 Posted March 29, 2023 Author Posted March 29, 2023 36 minutes ago, troggarf said: Found this a long time ago on a Chinese LISP forum: MinAreaRectangle.lsp 11.16 kB · 1 download This looks really cool but when I try to run it I get a ; bad argument type : 2d/3d point: nill error. Quote
Jamesclark64 Posted March 29, 2023 Author Posted March 29, 2023 1 hour ago, devitg said: @Jamesclark64, please upload a sample dwg. Sure. Here's two examples one vertical and one diagonal. example.dwg Quote
devitg Posted March 29, 2023 Posted March 29, 2023 18 minutes ago, Jamesclark64 said: Here's two examples one vertical and one diagonal. @Jamesclark64, but you ask for 2 side polys, no for 2 polys side Quote
Jamesclark64 Posted March 29, 2023 Author Posted March 29, 2023 17 minutes ago, devitg said: @Jamesclark64, 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. Quote
devitg Posted March 29, 2023 Posted March 29, 2023 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 Quote
Jamesclark64 Posted March 29, 2023 Author Posted March 29, 2023 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 Quote
devitg Posted March 30, 2023 Posted March 30, 2023 @Jamesclark64 Find attached DWG , and LISP draw rectangle from 3 vertex lwpolylines-01.LSP rectangles drawn from 3 vertex polys.dwg Quote
thecocuk07 Posted March 30, 2023 Posted March 30, 2023 (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 March 30, 2023 by thecocuk07 Quote
BIGAL Posted March 30, 2023 Posted March 30, 2023 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. Quote
Jamesclark64 Posted March 30, 2023 Author Posted March 30, 2023 15 hours ago, devitg said: @Jamesclark64 Find attached DWG , and LISP draw rectangle from 3 vertex lwpolylines-01.LSP 3.85 kB · 6 downloads rectangles drawn from 3 vertex polys.dwg 48.8 kB · 3 downloads This is fantastic! I can't thank you enough! Is there a way I can send you some dollars for a few beers? Quote
devitg Posted March 30, 2023 Posted March 30, 2023 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 Quote
Jamesclark64 Posted March 31, 2023 Author Posted March 31, 2023 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. Quote
thecocuk07 Posted March 31, 2023 Posted March 31, 2023 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 Quote
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.