samifox Posted May 3, 2013 Posted May 3, 2013 Hi I have an intersection rebars lines in which I need to extend. I painfully repeating this task by “Extend" E” “E” all intersection points How can I extend all selected lines ? and how I can limit the projection ? I need my routine to do the following Pick a closed polyline Offset 3 units inward Move the offset line to a layer named “CONS” Explode the polyline into lines Extend all line (consider lines in “CONS” only and/or don’t project more than x units) in the image the steps i take right to left Thanks Shay Quote
pBe Posted May 3, 2013 Posted May 3, 2013 Its only as matter of doing the math samifox. You can create the lines using the clearance between the rebar and concrete and the width of the concrete slab. Quote
samifox Posted May 3, 2013 Author Posted May 3, 2013 Its only as matter of doing the math samifox. You can create the lines using the clearance between the rebar and concrete and the width of the concrete slab. im not sure i following you, you mean to use polar() to draw? if so how can i tell when to extend and when not to? Quote
pBe Posted May 3, 2013 Posted May 3, 2013 Thats the thing. you dont need to extend, but instead you "draw" a line referencing the lower left corner and upper right corner of the pline. Pseudo code: Select outer polyline Select inner polyine get width of slab Offset the outer polyline 3 units inside Get coordinates of last entity line And yes.. polar to determine the points for new line. Quote
MSasu Posted May 3, 2013 Posted May 3, 2013 I believe that the progress into your sketch is from right to left, is this correct? Another function that may be of interest to you is INTERS. Quote
pBe Posted May 3, 2013 Posted May 3, 2013 I believe that the progress into your sketch is from right to left, is this correct?Another function that may be of interest to you is INTERS. Not sure how inters comes into play here Msasu? can you post a pseudo code using that approach. Anyhoo... I'm headed out so here's a demo (Defun c:demo ( / om pl pl2 dist ref mn mx h w a b c d) (setq om (getvar 'osmode)) (if (and (setq pl ([color="blue"]entsel [/color]"\nSelect Outer rim: ")) (setq pl2 ([color="blue"]entsel[/color] "\nSelect Inner rim: ")) (setq dist ([color="blue"]distance[/color] (vlax-curve-getClosestPointTo (car pl) (Cadr pl)) (vlax-curve-getClosestPointTo (car pl2) (Cadr pl))) ) ) (progn (command [color="blue"]"_offset" [/color]3 (Car pl) (Cadr pl2) "") ([color="blue"]vla-getboundingbox[/color] (setq e (vlax-ename->vla-object (entlast))) 'mn 'mx) (setq mn (vlax-safearray->list mn) mx (vlax-safearray->list mx) w (- (car mx) (car mn)) h (- (cadr mx) (cadr mn)) dist (- dist 6)) (foreach seg (list [color="blue"](list (setq a (polar mn 0 dist)) (polar a (/ pi 2.0) h)) (list (setq b (polar mn (/ pi 2.0) dist)) (polar b 0 w)) (list (setq c (polar mx pi dist)) (polar c (* pi 1.5) h)) (list (setq d (polar mx (* pi 1.5) dist)) (polar d pi w)))[/color] (entmakex (list (cons 0 "LINE") (cons 10 (Car seg)) (cons 11 (Cadr seg)) '(8 . "CONS"))) ) (vla-put-layer e "CONS") ) )(princ) ) Quote
MSasu Posted May 3, 2013 Posted May 3, 2013 Not sure how inters comes into play here Msasu? can you post a pseudo code using that approach. With pleasure! Considering the notation from sketch below: (setq point1st (polar pointITL (* 0.5 pi) theGap) point3rd (polar pointITR (* 0.5 pi) theGap)) (setq point2nd ([color=blue]inters[/color] point1st point3rd pointETL pointEBL nil) point4th ([color=blue]inters[/color] point1st point3rd pointETR pointEBR nil)) Quote
pBe Posted May 4, 2013 Posted May 4, 2013 I see now. (inters point1st point3rd pointETL pointEBL[color="blue"] [b]nil[/b][/color]) Ok, i'm sold. Cheers MSasu Quote
samifox Posted May 4, 2013 Author Posted May 4, 2013 PbE , your code works perfectly for rectangle only, im after a structure level solution here is a sketch (also dwg included) i want to extract rebars copy also beside the walls, se if ill find a way to collect verts 1 and 10 i can extract the rebar of the column, and if i collect verts 1 and 6 i can generate rebar for this portion of the wall the yellow circles are coordinates needed to generate rebars that cannot be extracted be normal vertices m like the rebar of 6,7,8,9 , in order to extract it i need to get a projection of 6 and 9 (as MSasu gave me food to think) hope it make sense is there a way to code it? Thanks Shay points.dwg Quote
pBe Posted May 4, 2013 Posted May 4, 2013 I think i have a quick idea HOW. but this time you will write the code: Here's a pseudo code: Select the pline. Create temporary points [Point entity] Find the points by selecting two "point" entities at a time. Example: base on your diagram (while ..... Selecting 2 point entities at point 1 and 10 will give you points at lower left and upper right [draw the line] Selecting 2 point entities at point 5 and 2 will give you points at upper left and lower right [draw the line] 17 & 22, 17 & 21, 20 & 22.... [note this numbers doesnt represent the real points, only for discussiion purposes] Now points 6, 7, 8 and 9 requires another approach. If selected points is more than 2, say all four..by dragging the pointer up and down using grread, the routine will "determine" where the next two points would be projected... ); end of while Remove all point entities created. Now for a more "automated" method, i need to get back to you on that. I'm sure i'm can think of something.. or maybe not. Quote
samifox Posted May 5, 2013 Author Posted May 5, 2013 I think i have a quick idea HOW. but this time you will write the code: Here's a pseudo code: Select the pline. Create temporary points [Point entity] Find the points by selecting two "point" entities at a time. Example: base on your diagram (while ..... Selecting 2 point entities at point 1 and 10 will give you points at lower left and upper right [draw the line] Selecting 2 point entities at point 5 and 2 will give you points at upper left and lower right [draw the line] 17 & 22, 17 & 21, 20 & 22.... [note this numbers doesnt represent the real points, only for discussiion purposes] Now points 6, 7, 8 and 9 requires another approach. If selected points is more than 2, say all four..by dragging the pointer up and down using grread, the routine will "determine" where the next two points would be projected... ); end of while Remove all point entities created. Now for a more "automated" method, i need to get back to you on that. I'm sure i'm can think of something.. or maybe not. thanks for the challenge i gave lots of thinking, the solution i come to is to draw the rebars in the order and the direction it was drawn please look at the attached image as it show what im after here is my pseudo code Loop Go to p1 Select all surrounding points in 50 units radius If members count is 2 (can be a wall end or a column) Measure distance between p1 p2 aka ”dis” (if it’s a column or wall end the range is 10-35 if “dis” is greater than 100 (it’s a wall) Draw line from p1, in angel of p2, 100 units Draw line from p2, in angel of p1, 100 units If “dis” is smaller than 100 Draw a line from p1 to p2 If member count is 4(for situation where vertecis are not defined (like vers 6,7,8,9) Project lines to all possible direction Draw lines between returned coordinates what you think? points3.dwg Quote
samifox Posted May 5, 2013 Author Posted May 5, 2013 no no no it wont work the way i need Pbe way is the best need more thinking time Quote
samifox Posted May 6, 2013 Author Posted May 6, 2013 Hi Yet Another idea, First to create my initial post request im gonna mark apparent and not apparent intersections coordinates, and than Il create rectangles all over but limit it for maximum segment length(wall) Than to extract rebars, I’ll ask the user to choose which rebars are to be extracted by selecting left botton point and upper right point of each rebar. Store those coordinatesin a list named “userCoor” and create reactance out of those coordinates I think this is the only way (I know of) to make this. What you think? shay Quote
pBe Posted May 6, 2013 Posted May 6, 2013 (defun c:demo ( / LWPoly _from pl pts temp corners ang mid v h 1p 2p objrot) ;;; Demo by pBe 06May2013 ;;; ;;; This demo will work only at the lower left corner and upper right corner ;;; ;;; It is written as a guide and not in any way complete and accurate ::; (setvar 'pdmode 34) (setvar 'cmdecho 0) (defun LWPoly (lst) (entmakex (append (list (cons 0 "LWPOLYLINE") (cons 100 "AcDbEntity") (cons 100 "AcDbPolyline") (cons 90 (length lst)) ) (mapcar (function (lambda (p) (cons 10 p))) lst)))) ;;; pBe05Nov2012 ;;; (defun _pBe:from (p d m) (polar p (* pi (nth m '(0.25 0.75 1.25 1.75))) (* d (sqrt 2)) ) ) (if (setq pl (car (entsel "\nSelect Pline:"))) (progn (setq pts (mapcar 'cdr (vl-remove-if-not '(lambda (e) (= (Car e) 10))(entget pl)))) (setq temp (ssadd)) (foreach p pts (command "_point" "_non" p) (ssadd (entlast) temp)) (While (setq corners nil pn (ssget '((0 . "POINT")))) ;;; Written to work with only two selected points ;;; (repeat 2 (setq corners (cons (cdr (assoc 10 (entget (ssname pn 0)))) corners) ) (ssdel (ssname pn 0) pn)) (setq corners (If (> (Cadr (car corners))(Cadr (cadr corners))) (reverse corners) corners )) (setq ang (angle (setq 1p (car corners))(setq 2p (cadr corners)))) (setq mid (mapcar '(lambda (x y) (* 0.5 (+ x y))) 1p 2p)) (Setq h (- (car 2p)(car 1p)) v (- (cadr 2p) (cadr 1p))) (setq pts_ (vl-sort (list 1p (list (car 1p) (cadr 2p)) 2p (list (car 2p) (cadr 1p)) ) '(lambda (a b) (cond ((> (cadr a) (cadr b)) T) ((equal (cadr a) (cadr b) 0.1) (< (car a) (car b))) ) ) ) ) (if (and (< ang (/ pi 2.0)) (< (car 1p)(car 2p))) (progn (setq st ( _pBe:from (caddr pts_) 2.5 0) objrot (ssadd) tr 0) (LWpoly (list (polar st (/ pi 2.0) 100) st (setq 3p (polar st 0 (- h 5.0))) (polar 3p (/ pi 2.0) 100) ) ) (ssadd (entlast) objrot) (LWpoly (list (polar st 0 100) st (setq 3p (polar st (/ pi 2.0) (- v 5.0))) (polar 3p 0 100) ) ) (ssadd (entlast) objrot) [b][color="blue"](prompt "\nMove Mouse up and down to rotate")[/color][/b] (while (progn (setq gr (grread t 15 0) mode (car gr) data (cadr gr) ) ;;; pBe 11Oct2010 ;;; (cond ((= 5 mode) (if ((if (zerop tr) < > ) pi (angle mid data) ) (setq tr (boole 6 1 tr) ro (command "_rotate" objrot "" "_non" mid 180) ) ) T ) ((member mode '(2 3)) nil) ) ) ) ) ) ) (command "_erase" temp "") ) )(princ) ) Again samifox: ;;; Demo by pBe 06May2013 ;;; ;;; This demo will work only at the lower left corner and upper right corner ;;; ;;; It is written as a guide and not in any way complete and accurate ::; You should be able to finish your program using the code above as a startpoint. Quote
samifox Posted May 6, 2013 Author Posted May 6, 2013 thank you pBe. its realy great start point for me! i need to learn your code before i can carry it on thanks again Shay Quote
samifox Posted May 6, 2013 Author Posted May 6, 2013 the script is really high coded , can you add some comments to the code? most of the function are new to me...i cant even ask a question Quote
pBe Posted May 7, 2013 Posted May 7, 2013 the script is really high coded , can you add some comments to the code? Seriously now samifox. the Help file is at the ready [F1] [b][color="blue"]TRY[/color][/b].. (if ("nose bleed")("then ask...")("Eureka! .. I got it!")) The best way to understand the code is to run the line one by one.... pause .. then try again... Repetition my good man.. repetition.... [You can do it] Quote
samifox Posted May 7, 2013 Author Posted May 7, 2013 I guess my “Beginner” privilege has been void now Ok thanks PBE Quote
pBe Posted May 7, 2013 Posted May 7, 2013 I guess my “Beginner” privilege has been void now .. its not that samifox. just want you to learn by forcing your gray matter to work overtime until it clicks. But if you really really need our help. you know where to find us. 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.