Grigs Posted July 11, 2012 Posted July 11, 2012 I can see how this would work, just can't write the code. Was wondering if someone could help. Basically, you would pick 3 points. The first 2 would determine the width and the 3rd would determine the length. Then, it would create a polygon using the width and length. I know it sounds weird, but it would really help. Thanks Quote
MSasu Posted July 11, 2012 Posted July 11, 2012 Something like this? ;;; 3 Points Polygon (11-VII-2012) (defun c:3PP( / point1st point2nd point3rd ) (while (and (setq point1st (getpoint "\nPick insertion point: ")) (setq point2nd (getpoint point1st "\nIndicate width: ")) (setq point3rd (getpoint point1st "\nIndicate length "))) (command "_RECTANGLE" "_non" point1st "_non" (list (+ (car point1st) (distance point1st point3rd)) (+ (cadr point1st) (distance point1st point2nd)))) ) (princ) ) Quote
Grigs Posted July 11, 2012 Author Posted July 11, 2012 Kinda. That draws a rectangle. What I need it a polyline. Quote
Tharwat Posted July 11, 2012 Posted July 11, 2012 Grigs said: Kinda. That draws a rectangle. What I need it a polyline. Upload a drawing shows your needs in it . Quote
MSasu Posted July 11, 2012 Posted July 11, 2012 Grigs said: Kinda. That draws a rectangle. What I need it a polyline. A rectangle is nothing more than a polyline entity. Quote
MSasu Posted July 11, 2012 Posted July 11, 2012 So you are looking in fact for a single segment polyline with width different than 0? Quote
Grigs Posted July 11, 2012 Author Posted July 11, 2012 Correct. The width would be determined by the first 2 points that are selected. I know the image looks a little different than what I am explaning, but honestly all I need is the base code that creates it. I can tweak it to do what I want it to end up looking like. Quote
Tharwat Posted July 11, 2012 Posted July 11, 2012 This ... ? (defun c:Test (/ p1 p2 vl gr) (vl-load-com) (if (and (setq p1 (getpoint "\n Specify first point :")) (setq p2 (getpoint p1 "\n Next point :")) ) (progn (vl-cmdf "_.pline" "_non" p1 "_non" p2 "") (setq vl (vlax-ename->vla-object (entlast))) (while (eq (car (setq gr (grread t 15 0))) 5) (redraw) (grdraw p1 (polar p1 (+ (angle p1 p2) (/ pi 2.)) (distance p1 (cadr gr))) 1 0) (vla-put-constantwidth vl (distance p1 (cadr gr))) ) ) (princ) ) (redraw) (princ) ) Quote
Grigs Posted July 11, 2012 Author Posted July 11, 2012 That's an interesting way to go about it. It seems that the 2 points define the length, then it has a rubberband effect that does the width. If there was a way to type in a width or pick 2 points for the width, it would be great. Quote
Tharwat Posted July 11, 2012 Posted July 11, 2012 Things like this ... ? (defun c:Test (/ p1 p2 w vl) (vl-load-com) (if (and (setq p1 (getpoint "\n Specify first point :")) (setq p2 (getpoint p1 "\n Next point :")) ) (vl-cmdf "_.pline" "_non" p1 "_non" p2 "") ) (if (setq w (getdist "\n Specify width of Polyline :")) (progn (setq vl (vlax-ename->vla-object (entlast))) (vla-put-constantwidth vl w) ) (princ) ) (princ) ) Quote
Tharwat Posted July 11, 2012 Posted July 11, 2012 Grigs said: Yeah, that works great. Thanks!!! You're very welcome . Quote
Tharwat Posted July 11, 2012 Posted July 11, 2012 Grigs said: Now just to tweak it abit If you need to add more options , just tell and I would be more than happy to modify it if I could make it . Quote
Grigs Posted July 11, 2012 Author Posted July 11, 2012 I just need to add error detection, layer control, setting/resetting of osnaps. Quote
Tharwat Posted July 11, 2012 Posted July 11, 2012 Grigs said: I just need to add error detection, layer control, setting/resetting of osnaps. Yeah , it is possible . What is the name of the layer that you want lay the drawn polyline on ? And the osnaps modes that you want to set them on just while running the routine ? Quote
Grigs Posted July 11, 2012 Author Posted July 11, 2012 Well, I think I have those figured out. It detects if the layer is there or not. If it is there, then it sets that layer current. If not, it creates it. I've got that implenented, just need to save the current layer and reset it back. Quote
Tharwat Posted July 11, 2012 Posted July 11, 2012 Ok , just post the name of the layer and its settings (color , Lineweight , LType ) Quote
Grigs Posted July 11, 2012 Author Posted July 11, 2012 (edited) Here is the code I came up with to deal with the layer: Quote (if (tblsearch "layer" "A-Wall-Patt") (command "layer" "s" "A-Wall-Patt" "") (command "layer" "m" "A-Wall-Patt" "c" "252" "A-Wall-Patt" "") ) Edited July 11, 2012 by Grigs 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.