Jump to content

Recommended Posts

Posted

Hello every reader,

 

Well i'm working on a routine here ill post a picture to show you what it make.

 

for info.JPG

 

but i want to have the chose either to reproduce this on the left or the right

 

so i used the function getkword, if and progn to simulate it.

 

now when i choose right it doesnt work.

 

here's the

(defun c:cofp (/ rep pt1 pt2)

 (setq pt1 (getpoint "\nClick on the first point ! "))
 (setq pt2 (getpoint "\nClick on the second point ! "))

 (initget 1 "left right")
 (setq rep (getkword "\nChoose the side of the beam [left/right] "))
   (if (= rep Gauche)
     (progn
     
       (setq pt3 (list (- (car pt2) 20) (cadr pt2)))
       (setq pt4 (list (- (car pt1) 20) (cadr pt1)))
       (setq pt5 (list (- (car pt4) 90) (+ (cadr pt4) 20)))
       (setq pt6 (list (- (car pt4) 90) (cadr pt4)))
       (setq pt7 (list (car pt3) (- (cadr pt3) 38)))
       (setq pt8 (list (car pt3) (- (cadr pt3) 76)))
     
     );progn
   );if

   (if (= rep Droite)
     (progn
     
       (setq pt3 (list (+ (car pt2) 20) (cadr pt2)))
       (setq pt4 (list (+ (car pt1) 20) (cadr pt1)))
       (setq pt5 (list (+ (car pt4) 90) (+ (cadr pt4) 20)))
       (setq pt6 (list (+ (car pt4) 90) (cadr pt4)))
       (setq pt7 (list (car pt3) (- (cadr pt3) 38)))
       (setq pt8 (list (car pt3) (- (cadr pt3) 76)))

     );progn
   );if
  
 (setq os (getvar 'OSMODE))
 (setvar 'OSMODE 0)
 
 (command "_insert" "2 x 4" pt6 "" "1" "")
 (command "_insert" "2 x 4" pt7 "" "1" "")
 (command "_insert" "2 x 4" pt8 "" "1" "")
 (command "_rectangle" pt1 pt3)
 (command "_rectangle" pt4 pt5)
 (command "_rectangle" pt5 pt8)

 (setvar 'OSMODE os)
 
);defun c:

 

So here it is !

 

thanks for the help in advance!

 

Cheers beers.

Posted

Try

 

(defun c:cofp (/ rep pt1 pt2)
 (setq pt1 (getpoint "\nClick on the first point ! "))
 (setq pt2 (getpoint "\nClick on the second point ! "))
 (initget 1 "L R")
 (setq rep (getkword "\nChoose the side of the beam [Left/Right] "))
   (if (= rep "L")
     (progn

       (setq pt3 (list (- (car pt2) 20) (cadr pt2)))
       (setq pt4 (list (- (car pt1) 20) (cadr pt1)))
       (setq pt5 (list (- (car pt4) 90) (+ (cadr pt4) 20)))
       (setq pt6 (list (- (car pt4) 90) (cadr pt4)))
       (setq pt7 (list (car pt3) (- (cadr pt3) 38)))
       (setq pt8 (list (car pt3) (- (cadr pt3) 76)))

     );progn
   );if
   (if (= rep "R")
     (progn

       (setq pt3 (list (+ (car pt2) 20) (cadr pt2)))
       (setq pt4 (list (+ (car pt1) 20) (cadr pt1)))
       (setq pt5 (list (+ (car pt4) 90) (+ (cadr pt4) 20)))
       (setq pt6 (list (+ (car pt4) 90) (cadr pt4)))
       (setq pt7 (list (car pt3) (- (cadr pt3) 38)))
       (setq pt8 (list (car pt3) (- (cadr pt3) 76)))
     );progn
   );if

 (setq os (getvar 'OSMODE))
 (setvar 'OSMODE 0)
 (command "_insert" "2 x 4" pt6 "" "1" "")
 (command "_insert" "2 x 4" pt7 "" "1" "")
 (command "_insert" "2 x 4" pt8 "" "1" "")
 (command "_rectangle" pt1 pt3)
 (command "_rectangle" pt4 pt5)
 (command "_rectangle" pt5 pt8)
 (setvar 'OSMODE os)

);defun c:

Posted

Hi Thank for the help it works! i think i forgot the ""

Posted

A shorter way maybe 2 clicks first pick pick line you can get start & end pts then compare pick point to figure out top bottom etc swap pts the 2nd pick is direction required.

 

Code is copyrighted but a snippet

(setq tp1 (entsel "\nSelect left side inner wall near end : "))
 (setq tpp1 (entget (car tp1)))
 (setq pt1 (cdr (assoc 10 tpp1)))     ;start 
 (setq pt2 (cdr (assoc 11 tpp1)))   ; end
 (setq pt3 (cadr tp1)) ;pick point

Just compare distance pt3-pt1 pt3-pt2 the shorter is your start point. 

Posted

Hi Bigal,

 

I tried what you posted but i'm not sure it works when it's a pline.

 

But since i want to make sure my pt1 is always the one in the bottom would there be a way to do it?

 

cheers beers

Posted

The draw stud I have is based on a complete package so it expects lines you probbably could get it still to work with plines but the code will become a lot bigger,with some other stuff just took the cheap way out if pline then explode and continue.

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