Jump to content

Recommended Posts

Posted (edited)

I am trying to break 2 parallel lines and draw closing lines and intersections.

I try to use getpoint to make a point somewhere at the line but it is not working.

does somebody has a solution?

 

and following insert of an object.

parlinesbreak.dwg

parlines.dwg

Edited by s1222s
Posted

Hi,

 

Try this.

 

 
(defun c:BRK()
 (setq snp (getvar "OSMODE"))
 (setvar "OSMODE" 0)
 (setq ent (entsel "\nSelect line to break"))
 (setq po (cadr ent))
 (setq ent (car ent))
 (setq vlent (vlax-ename->vla-object ent))
 (setq po (vlax-curve-getclosestpointto vlent po))
 
 (setq po1 (getpoint po "\nSelect next point to break"))
 (setq po1 (vlax-curve-getclosestpointto vlent po1))
 (setq ent1 (car (entsel "\nSelect parallen entity")))
 (setq vlent1 (vlax-ename->vla-object ent1))
 (setq po2 (vlax-curve-getclosestpointto vlent1 po))
 (setq po3 (vlax-curve-getclosestpointto vlent1 po1))
 (command "Break" ent po po1)
 (command "Break" ent1 po2 po3)
 (command "line" po po2 "")
 (command "line" po1 po3 "")
 (setvar "OSMODE" snp)
 )

Posted

Another:

 

(defun c:br2 (/ lines pt1 pt2 ol plst)
;;;	pBe Sep 2012	;;;
(vl-load-com)
 (prompt "\nSelect Objects to Break:")
 (cond
   ((and
      (setq plst  nil
     lines (ssget ":L" '((0 . "LINE")))
      )
      (= (sslength lines) 2)
      (setq pt1 (getpoint "\nPick first point:"))
      (setq pt2 (getpoint pt1 "\nPick second point:"))
      (repeat (sslength lines)
 (setq ol (ssname lines 0))
 (setq plst (cons (vlax-curve-getclosestpointto ol pt1) plst)
       plst (cons (vlax-curve-getclosestpointto ol pt2) plst)
 )
 (command "_break" ol "_non" pt1 "_non" pt2)
 (ssdel ol lines)
      )
      (mapcar '(lambda	(j)
	  (entmakex (list (cons 0 "LINE")
			  (cons 10 (nth (Car j) plst))
			  (cons 11 (nth (Cadr j) plst))
		    )
	  )
	)
       '((0 2) (1 3))
      )
    )
   )
 )
 (princ)
)

 

HTH

Posted (edited)

Thanks. Its working but not at all.

That is I am trying to do:

brklns.dwg

 

 

Part of my code:

(defun c:WR1 ( / aa b c c5 c6 c7 c8 cc3 d l la lb dr wbl)

 (setq bl (getvar "BLIPMODE"))
 (setq cm (getvar "CMDECHO"))
 (setvar "CMDECHO" 0)

 (if (not doorw)
   (setq doorw 0.9)
 )
 (initget 2)
 (setq dr (getdist (strcat "Door with: <" (rtos doorw 2 2) ">")))
 (if dr
   (setq doorw dr)
 )

 ;(setq a1 (cdr (assoc 10 (entget (car (entsel))))))
 
 (setq aobject (cdr (entget (car (entsel "\nSelect first line: ")))))
 (setq a1 (cdr (assoc 10 (cdr aobject))))
 (setq a2 (cdr (assoc 11 (cdr aobject))))
 (setq bobject (cdr (entget (car (entsel "\nSelect second line: ")))))
 (setq b1 (cdr (assoc 10 (cdr bobject))))
 (setq b2 (cdr (assoc 11 (cdr bobject))))

 (setq _c (getpoint "\nBase point: "))
 (initget 1 "Left Right:")
 (setq d (getkword "\nLeft or Right?"))


(setq _la (angle a1 a2))
 (setq _lb (angle b1 b2))
 (setq lac (angle a1 _c))
 
 (setq c1 (polar a1 _la (* (cos (- _la lac)) (distance a1 _c))))
 (setq cd (distance a1 b1))
 (setq lbc (angle b1 (polar _c (+ _lb (* 0.5 pi)) (* (cos (- _lb lbc)) cd)))) 
 (setq c2 (polar b1 (+ _lb (* 0.5 pi)) (* (cos (- _lb lbc)) cd)))

 

..........................

That "_c" point is not on the place where I've picked it (base point).

Edited by s1222s
Posted (edited)

With prompt for Door Width:

 

(defun c:br2 (/ lines pt1 pt2 ol  plst)
;;;	pBe Sep 2012	;;;
(vl-load-com)
 (prompt "\nSelect Objects to Break:")
 (cond
   ((and
      (setq plst  nil
     lines (ssget ":L" '((0 . "LINE")))
      )
      (= (sslength lines) 2)
      [color="blue"](setq dr (cond
((getdist (strcat "\nEnter Window width"
                (if dr (strcat " <" (rtos dr) ">: ") ": ")
                           )))(dr))
               )[/color]
      (setq pt1 (getpoint "\nPick first point:"))
      (setq pt2 (getpoint pt1 "\nPick second point for direction:"))
      [color="blue"](setq pt2 (polar pt1 (angle pt1 pt2) dr))[/color]
      (repeat (sslength lines)
 (setq ol (ssname lines 0))
 (setq plst (cons (vlax-curve-getclosestpointto ol pt1) plst)
       plst (cons (vlax-curve-getclosestpointto ol pt2) plst)
 )
 (command "_break" ol "_non" pt1 "_non" pt2)
 (ssdel ol lines)
      )
      (mapcar '(lambda	(j)
	  (entmakex (list (cons 0 "LINE")
			  (cons 10 (nth (Car j) plst))
			  (cons 11 (nth (Cadr j) plst))
		    )
	  )
	)
       '((0 2)
	 (1 3))
      )
    )
   )
 )
 (princ)
)

 

BTW: Welcome to the Forum

Please do read this Code Posting Guidelines

Edited by pBe
Posted

Great thanks. Its working.

I see a lot of thinks need to be clarified in autolisp:)

But with getpoint is possible to get a point because I thought it was wrong, right.

Posted

Ok. Why do I really need "vlax-curve-getClosestPoint" in that lisp?!

Posted

Is this what your trying to do, plus lots more if so private email me the add on to do simple house designs is still avaialble can supply details

 

door.jpg

Posted

Isnt it possible to be prepared this lisp without "VL" things. I dont need it and want to be made pure lisp without visual lisp and use Left or Right for direction.

Posted

All you have to do is use the polar command to work out the intersecting points on the other wall skins then use break and draw lines etc Always pick either inside or outside line then you know which way wall is located. The example I posted is created via all plain old fashioned lisp. But I would go down the VL way now removes lots of coding.

 

pi3 is 270 deg 
door line pts b d
wall w2 w3 w4 double skin wall
(setq pt3 (polar b (+ pi3 (angle b d)) (+ w2 w3 w4)))

  • 3 weeks later...
Posted

sorry but what is:

 

door line pts b d

wall w2 w3 w4 double skin wall

Posted (edited)

Anybody here ordered Vanilla?

 

(defun c:brV ( / osm d w1 w2 pt1 pt2 pt3 pt4)
(setq osm (getvar 'Osmode))
(setvar 'osmode 0)
 (setq d (getdist "\nEnter Door width: "))
 (setq	w1 (entsel "\nPick one side of the wall: ")
w2 (entsel "\nPick other side of the wall: ")
 )
 (command "_line"
   (setq pt1 (osnap (cadr w1) "_nea"))
   (setq pt2 (osnap (cadr w2) "_per"))
   ""
 )
 (setvar 'osmode 512)
 (setq dir (Getpoint pt1 "\nPick point for Direction:"))
 (setvar 'osmode 0)
 (command
   "_line"
   (setq pt3 (polar pt1 (angle pt1 dir) d))
   (osnap (setq pt4 (polar pt3 (angle pt1 pt2) (distance pt1 pt2)))
   "_per"
   )
   ""
 )
 (command "_break" (car w1) pt1 pt3)
 (command "_break" (car w2) pt2 pt4)
(setvar 'osmode osm)
(princ)  
)

 

Usage:

command: brv

Edited by pBe
Posted

Must have had a brain drian when I posted above Further to PBe code you only need pick line once pick left side of door enter distance from end therefore know right side of door on line via polar then can do break. The pick point for direction is not needed as you pick door on left side of wall implying which way is say in. You get used to left and right very quick even when upside down.

 

I would post the code but its copyrited.

Posted
Anybody here ordered Vanilla?

 

(defun c:brV ( / osm d w1 w2 pt1 pt2 pt3 pt4)
(setq osm (getvar 'Osmode))
(setvar 'osmode 0)
 (setq d (getdist "\nEnter Door width: "))
 (setq	w1 (entsel "\nPick one side of the wall: ")
w2 (entsel "\nPick other side of the wall: ")
 )
 (command "_line"
   (setq pt1 (osnap (cadr w1) "_nea"))
   (setq pt2 (osnap (cadr w2) "_per"))
   ""
 )
 (setvar 'osmode 512)
 (setq dir (Getpoint pt1 "\nPick point for Direction:"))
 (setvar 'osmode 0)
 (command
   "_line"
   (setq pt3 (polar pt1 (angle pt1 dir) d))
   (osnap (setq pt4 (polar pt3 (angle pt1 pt2) (distance pt1 pt2)))
   "_per"
   )
   ""
 )
 (command "_break" (car w1) pt1 pt3)
 (command "_break" (car w2) pt2 pt4)
(setvar 'osmode osm)
(princ)  
)

 

Usage:

command: brv

 

Hello PBE!

 

Great Lisp. Unfortunately, I can not use an object snap. If this were possible in this Lisp or not?

 

Best regards Martin

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