Sooshiant Posted March 20, 2014 Posted March 20, 2014 I have hundreds of lines with different length and need to change each to a rectangular with the same length and a specified width. Is there any way to do that for all easily? Quote
Tharwat Posted March 20, 2014 Posted March 20, 2014 Would the width going to be the same as the length of each line or it should be given from a user ? Would want to delete the selected lines after the process ? can you upload a sample drawing ? Quote
Sooshiant Posted March 20, 2014 Author Posted March 20, 2014 The length of each rectangular is the same the primitive line or pline but the width specifies by user. The resulting rectangular middle center is coincident to line middle point. Then delete first line. I'm new to here and don't know where can I upload files. Thanks for taking time brother Tharwat Quote
MSasu Posted March 20, 2014 Posted March 20, 2014 Here you will find an article on how to attach files. Please contact a Moderator to join your two threads related to the same mater. Quote
pBe Posted March 20, 2014 Posted March 20, 2014 The length of each rectangular is the same the primitive line or pline but the width specifies by user. ... Would there be an arc segment? if YES, look into Lee Macs Polyline Outline routine. Quote
Sooshiant Posted March 20, 2014 Author Posted March 20, 2014 I don't have any arc in my drawings but may be some one else has one. You know this app can be used in structural shop drawings widely. You can assume all are lines and there is no polygons. Quote
pBe Posted March 20, 2014 Posted March 20, 2014 I don't have any arc in my drawings but may be some one else has one. You know this app can be used in structural shop drawings widely. You can assume all are lines and there is no polygons. Just to be on the clear. Does that include polylines more than 1 segment? I would check the link i posted earlier if there is still the possibility of a polyline containing an arc segment. Quote
Sooshiant Posted March 20, 2014 Author Posted March 20, 2014 There is no arc. Is this clear enough ? Quote
pBe Posted March 20, 2014 Posted March 20, 2014 There is no arc. Is this clear enough ? Clear as frog hair. now what about multi-segment polyline? [polyline more than two points that is] Quote
Sooshiant Posted March 20, 2014 Author Posted March 20, 2014 pBe no there is no polylines we just have some lines as u see in case 1 and want to change them to case 2 relate to their center point. Quote
pBe Posted March 20, 2014 Posted March 20, 2014 (edited) pBe no there is no polylineswe just have some lines as u see in case 1 and want to change them to case 2 relate to their center point. The length of each rectangular is the same the primitive line or pline but the width specifies by user. could've sworn that is spelled as pline Try this: (defun c:l2r ( / ss e ent ang pts) (if (not width) (setq width 1.00)) (setq width (cond ((getdist (strcat "\nEnter Width <" (rtos width 2 2) ">: "))) (width))) (if (setq ss (ssget '((-4 . "<OR") (-4 . "<AND")(0 . "LWPOLYLINE")(90 . 2)(42 . 0)(-4 . "AND>") (0 . "LINE")(-4 . "OR>")))) (repeat (setq i (sslength ss)) (setq e (ssname ss (Setq i (1- i)))) (setq ent (entget e) ang (angle (setq sp (vlax-curve-getStartPoint e)) (setq ep (vlax-curve-getendPoint e)) ) ) (setq pts (mapcar '(lambda (pt) (list (setq p_ (polar pt (+ ang (/ pi 2.0)) (* 0.5 width)) ) (polar p_ (+ ang (* pi 1.5)) width) ) ) (list sp ep) ) pts (apply 'append (list (car pts) (reverse (cadr pts)))) ) (entmakex (append (list (cons 0 "LWPOLYLINE") (cons 100 "AcDbEntity") (assoc 8 ent) (cons 100 "AcDbPolyline") (cons 90 (length pts)) (cons 70 1) ) (mapcar (function (lambda (p) (cons 10 p))) pts) ) ) (entdel e) ) ) ) Multi segment /Arc segmnent (defun c:l2r2 ( / ss i e pts ob) (setq pac (getvar 'peditaccept)) (setvar 'peditaccept 1) (if (not width) (setq width 1.00)) (setq width (cond ((getdist (strcat "\nEnter Width <" (rtos width 2 2) ">: "))) (width))) (if (setq ss (ssget '((0 . "LWPOLYLINE,LINE")))) (repeat (setq i (sslength ss)) (setq e (ssname ss (Setq i (1- i))) sss (ssadd)) (setq pts (mapcar '(lambda (y) (list (vlax-curve-getStartPoint y) (vlax-curve-getEndPoint y) ) ) (mapcar 'car (mapcar '(lambda (x) (setq ob (vlax-invoke (vlax-ename->vla-object e) 'Offset x ) ) (ssadd (entlast) sss) ob ) (list (setq h (* 0.5 width)) (- h) ) ) ) ) ) (mapcar '(lambda (k l) (entmakex (list (cons 0 "LINE") (cons 10 k) (cons 11 l))) (ssadd (entlast) sss) ) (car pts)(cadr pts) ) (command "_.pedit" "_m" sss "" "_j" 0.0 "") (entdel e) ) ) (setvar 'peditaccept pac) (princ) ) Edited March 20, 2014 by pBe Quote
Sooshiant Posted March 20, 2014 Author Posted March 20, 2014 THANKSSSSSSSS pBe. Youre genius man. How can I do in return? May I deposit money? Quote
David Bethel Posted March 20, 2014 Posted March 20, 2014 Why not a simple PEDIT call ? Command: pedit Select polyline: (pause) or ename Object selected is not a polyline Do you want to turn it into one? <Y> y Close/Join/Width/Edit vertex/Fit/Spline/Decurve/Ltype gen/Undo/eXit <X>: Width Enter new width for all segments: 0.5 Close/Join/Width/Edit vertex/Fit/Spline/Decurve/Ltype gen/Undo/eXit <X>:eXit -David Quote
Snownut Posted March 20, 2014 Posted March 20, 2014 Clear as frog hair. now what about multi-segment polyline? [polyline more than two points that is] That's (frog hair) a new one, goes along with "is a frogs ass water tight ?". Quote
Sooshiant Posted March 20, 2014 Author Posted March 20, 2014 Why not a simple PEDIT call ? Editing width by pedit just change the visibility of line but the code pBe wrote reshapes a line to a rectangle which help user to draw more details based on rectangular's edges and sides by snap mode solutions. Quote
EthanY Posted March 21, 2014 Posted March 21, 2014 I gave it a try too. But my code is a bit messy, not as clear as pBe's. And its compatibility is not tested. Cheers, ; Covert multiple lines or plines to rectangles with given width ; 21 MAR 2014 @ MELBOURNE ; [email="yxinst@gmail.com"]yxinst@gmail.com[/email] (vl-load-com) (princ) (defun c:L2REC (/ _ss->lst subl2rec ss obs odist ) (defun _ss->lst (sset / i lst) (setq i 0) (while (< i (sslength sset)) (setq lst (cons (vlax-ename->vla-object (ssname sset i)) lst)) (setq i (+ i 1)) ) lst ) ;offset in 2 directions and link ends (defun subl2rec (oblst dist / l1 l2 l3 l4 temp pt11 pt12 pt21 pt22) (mapcar '(lambda (x) (setq l1 (vlax-vla-object->ename (car (vlax-safearray->list (vlax-variant-value (vla-offset x dist)) ) ) ) l2 (vlax-vla-object->ename (car (vlax-safearray->list (vlax-variant-value (vla-offset x (- 0 dist))) ) ) ) ) (if (/= "LINE" (cdr (assoc 0 (entget l1)))) (progn (command "_explode" l1) (setq l1 (entlast)) (command "_explode" l2) (setq l2 (entlast)) ) ) (setq pt11 (cdr (assoc 10 (entget l1))) pt12 (cdr (assoc 11 (entget l1))) pt21 (cdr (assoc 10 (entget l2))) pt22 (cdr (assoc 11 (entget l2))) ) (if (equal (distance pt11 pt22) (* 2 dist)) (setq temp pt22 pt22 pt21 pt21 temp ) ) (command "_line" pt11 pt21 "") (setq l3 (entlast)) (command "_line" pt12 pt22 "") (setq l4 (entlast)) (command "_pedit" l1 "y" "j" l3 "" "j" l2 "" "j" l4 "" "") ) oblst ) ) (princ "Select multiple lines or plines please.") (setq ss (ssget)) (setq obs (_ss->lst ss)) (setq odist (/ (getreal "Width?: ") 2)) (subl2rec obs odist) (command "erase" ss "") (princ) ) 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.