Jump to content

Recommended Posts

Posted

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

  • Replies 27
  • Created
  • Last Reply

Top Posters In This Topic

  • Grigs

    14

  • Tharwat

    10

  • MSasu

    3

  • SLW210

    1

Top Posters In This Topic

Posted Images

Posted

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

Posted

Kinda. That draws a rectangle. What I need it a polyline.

Posted
  Grigs said:
Kinda. That draws a rectangle. What I need it a polyline.

Upload a drawing shows your needs in it .

Posted
  Grigs said:
Kinda. That draws a rectangle. What I need it a polyline.

A rectangle is nothing more than a polyline entity.

Posted

So you are looking in fact for a single segment polyline with width different than 0?

Posted

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.

Posted

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

Posted

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.

Posted

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

Posted

Yeah, that works great. Thanks!!!

Posted
  Grigs said:
Yeah, that works great. Thanks!!!

 

You're very welcome . :)

Posted
  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 . :)

Posted

I just need to add error detection, layer control, setting/resetting of osnaps.

Posted
  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 ?

Posted

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.

Posted

Ok , just post the name of the layer and its settings (color , Lineweight , LType )

Posted (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 by Grigs

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