| Author |
Message |
Gary Fowler
Guest
|
Posted:
Wed Apr 06, 2005 11:06 pm Post subject:
Get points using entlast |
|
|
Using (entlast), how would you get the two end points if the
object is a line? Also the midpoint?
Sorry, I'm brain dead right now.
(setq pnts (list (cdr (assoc 10 (entget (entlast))))(cdr (assoc 11 (entget
(entlast))))))?
--
Gary Fowler - Architect
gdfowler@hotmail.com
|
|
| Back to top |
|
 |
Jeff Mishler
Guest
|
Posted:
Wed Apr 06, 2005 11:14 pm Post subject:
Re: Get points using entlast |
|
|
Something like this.....
(setq ent (entget (entlast))
startPt (cdr (assoc 10 ent))
endPt (cdr (assoc 11 ent))
midPt (mapcar '/ (mapcar '+ startPt endPt) '(2.0 2.0 2.0))
)
--
Jeff
check out www.cadvault.com
"Gary Fowler" <fowler@architettura-inc.com> wrote in message
news:42543342$1_2@newsprd01...
| Quote: | Using (entlast), how would you get the two end points if the
object is a line? Also the midpoint?
Sorry, I'm brain dead right now.
(setq pnts (list (cdr (assoc 10 (entget (entlast))))(cdr (assoc 11 (entget
(entlast))))))?
--
Gary Fowler - Architect
gdfowler@hotmail.com
|
|
|
| Back to top |
|
 |
Gary Fowler
Guest
|
Posted:
Wed Apr 06, 2005 11:30 pm Post subject:
Re: Get points using entlast |
|
|
Perfect, once I have another cup....I will
work on my emailing skills.
Thanks again
[_]P
--
Gary Fowler - Architect
gdfowler@hotmail.com
"Jeff Mishler" <jeff_m@cadvault.com> wrote in message
news:4254351d_3@newsprd01...
| Quote: | Something like this.....
(setq ent (entget (entlast))
startPt (cdr (assoc 10 ent))
endPt (cdr (assoc 11 ent))
midPt (mapcar '/ (mapcar '+ startPt endPt) '(2.0 2.0 2.0))
)
--
Jeff
check out www.cadvault.com
"Gary Fowler" <fowler@architettura-inc.com> wrote in message
news:42543342$1_2@newsprd01...
Using (entlast), how would you get the two end points if the
object is a line? Also the midpoint?
Sorry, I'm brain dead right now.
(setq pnts (list (cdr (assoc 10 (entget (entlast))))(cdr (assoc 11
(entget
(entlast))))))?
--
Gary Fowler - Architect
gdfowler@hotmail.com
|
|
|
| Back to top |
|
 |
Gary Fowler
Guest
|
Posted:
Thu Apr 07, 2005 12:09 am Post subject:
Re: Get points using entlast |
|
|
Here is the routine I was wanting to modify. Jeff Mishler provided
the missing part. The routine inserts text centered between two
parallel lines and matches the line rotation. I am sure there
are easier ways to do this...but for now this is working. I still
have a lot of code cleanup to do...............
Thanks again Jeff.
| Code: |
(defun ARCH:CEN-BETWEEN-LIN2 (/ a b p1 p2 pt ent1 ent2 ent3 elist)
(if (not ARCH:GetIntersect)
(load (strcat ARCH#UTIF "ARCH_GET_INTERSECT")))
(defun CEN-BETWEEN-LIN-DOIT ()
(command "line" a b "")
(setq ent1 (entlast))
(cond (SS1
(repeat (sslength SS1)
(setq ent2 (cdr (assoc -1 (entget (ssname SS1 0)))))
(setq p1 (ARCH:GetIntersect ent1 ent2))
(setq ent3 (cdr (assoc -1 (entget (ssname SS1 1)))))
(setq p2 (ARCH:GetIntersect ent1 ent3)))))
(command "dist" "nea" p1 "per" p2)
(setq dist_1 (getvar "distance"))
(setq dist_2 (/ dist_1 2.0))
(setq x (/ (+ (car p1) (car p2)) 2))
(setq y (/ (+ (cadr p1) (cadr p2)) 2))
(setq z (/ (+ (caddr p1) (caddr p2)) 2))
(setq p3 (list x y z))
(command "offset" dist_2 ent2 p3 "")
(entdel ent1)
(princ))
(setvar "orthomode" 0)
(setvar "osmode" 0)
;;(initget 1)
(setq a (getpoint "\n* Draw Crossing Line *"))
(initget 33)
(setq b (getpoint a))
(setq pt (list a b))
(setq SS1 (ssget "F" pt '((0 . "LINE"))))
(cond
((or (= SS1 nil) (/= (sslength SS1) 2))
(ARCH:ALERT-E
"MsgBox \"
Selection Error Message
--------------------------------------------------------------------------------------------
Invalid Selection...either you selected nothing, a
double line <line on top of a line>, or a polyline.
If a double line, delete one, or if a polyline
change it to a line. Now you can try again...\""))
((CEN-BETWEEN-LIN-DOIT)))
(princ))
(defun c:WAL-2X6IT (/ ent entl startPt endPt angl)
;;(ARCH:F_S-VAR)
(setvar "osmode" 0)
(setvar "orthomode" 0)
(ARCH:CEN-BETWEEN-LIN2)
(command "change" "l" "" "p" "lt" "hidden" "c" "6" "")
;;(ARCH:CUSTOM_LAYERS-ANNO)
;;(ARCH:SET-NOTES)
(setq ITEM "2x6")
(setq entl (entlast))
(setq ent (entget (entlast))
startPt (cdr (assoc 10 ent))
endPt (cdr (assoc 11 ent))
midPt (mapcar '/ (mapcar '+ startPt endPt) '(2.0 2.0 2.0))
);;Jeff Mishler
(setvar "osmode" 0)
;;p3 from ARCH:CEN-BETWEEN-LIN2...global var
(if p3 (command "_.text" "j" "mc" p3 "" 0 ITEM))
(setvar "osmode" 0)
(setq ang (angle startPt endPt))
(if (and (<= ang 4.71239) (> ang 1.5708))
(setq ang (angle endPt startPt))
)
(setq angl (car (list (cons 50 ang))))
(setq N 0)
(setq TXT (ssget "L"))
(repeat (sslength TXT)
(setq
Elist
(subst
angl
(assoc 50 (entget (ssname TXT N)))
(entget (ssname TXT N))
)
)
(entmod Elist)
(entupd (ssname TXT N))
(setq N (+ N 1))
)
(entdel entl)
(setq p3 nil)
;;(ARCH:F_R-VAR)
(princ)
)
(c:WAL-2X6IT)
|
--
Gary Fowler - Architect
gdfowler@hotmail.com
"Gary Fowler" <fowler@architettura-inc.com> wrote in message
news:42543342$1_2@newsprd01...
| Quote: | Using (entlast), how would you get the two end points if the
object is a line? Also the midpoint?
Sorry, I'm brain dead right now.
(setq pnts (list (cdr (assoc 10 (entget (entlast))))(cdr (assoc 11 (entget
(entlast))))))?
--
Gary Fowler - Architect
gdfowler@hotmail.com
|
|
|
| Back to top |
|
 |
Gary Fowler
Guest
|
Posted:
Thu Apr 07, 2005 12:12 am Post subject:
Re: Get points using entlast |
|
|
Sorry, I forgot to include this code.
| Code: |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;; Get the Intersection Function
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;One of the better ways is to use the IntersectWith method:
;;;Written by R. Robert Bell
;;;Takes either ENames or Objects, returns list or nil.
(defun ARCH:GetIntersect (obj1 obj2)
(foreach
obj '(obj1 obj2)
(if (= (type (eval obj)) 'ENAME)
(set obj
(vlax-EName->vla-Object
(eval obj)
)
)
)
)
(vlax-Invoke obj1 'IntersectWith obj2 acExtendBoth)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun C:TEST (/ a b pt ss1 ent1 ent2 ent3)
(setq t1 nil t2 nil)
(setvar "orthomode" 1)
(initget 1)
(setq a (getpoint "\n* Draw Crossing Line *"))
(initget 33)
(setq b (getpoint a))
(setq pt (list a b))
(setq SS1 (ssget "F" pt '((0 . "LINE"))))
(command "line" a b "")
(setq ent1 (entlast))
(cond
(SS1
(repeat (sslength SS1)
(setq ent2 (cdr (assoc -1 (entget (ssname SS1 0)))))
(setq t1 (ARCH:GetIntersect ent1 ent2))
(setq ent3 (cdr (assoc -1 (entget (ssname SS1 1)))))
(setq t2 (ARCH:GetIntersect ent1 ent3))
)
)
)
(princ t1)
(princ t2)
(entdel ent1)
(princ)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun CFLITx (/ p1 p2 a b pt ss1 ent1 ent2 ent3 pkrobj)
(ARCH:F_S-VAR)
(setq t1 nil t2 nil)
(setvar "orthomode" 1)
(initget 3)
(setq pkrobj (entsel "\n* Select line...*"))
(setq p1 (cdr (assoc 10 (entget (car pkrobj)))))
(setq p2 (cdr (assoc 11 (entget (car pkrobj)))))
(setvar "orthomode" 1)
(setvar "SNAPANG" (angle p1 p2))
(setq a (cadr pkrobj))
(initget 33)
(setvar "osmode" 0)
(setq b (getpoint a "\n* pick point...*"))
(setq pt (list a b))
(setq SS1 (ssget "F" pt '((0 . "LINE"))))
(command "line" a b "")
(setq ent1 (entlast))
(cond
(SS1
(repeat (sslength SS1)
(setq ent2 (cdr (assoc -1 (entget (ssname SS1 0)))))
(setq t1 (ARCH:GetIntersect ent1 ent2))
(setq ent3 (cdr (assoc -1 (entget (ssname SS1 1)))))
(setq t2 (ARCH:GetIntersect ent1 ent3))
)
)
)
(princ t1)
(princ t2)
(if ent1 (entdel ent1))
(ARCH:F_R-VAR)
(princ)
)
(defun mid (w z)
(LIST (/ (+ (CAR w) (CAR z)) 2) (/ (+ (CADR w) (CADR z)) 2))
)
(defun CFLIT (/ p1 p2 a b pt ss1 ent1 ent2 ent3 pkrobj)
(ARCH:F_S-VAR)
(setq t1 nil t2 nil)
(setvar "orthomode" 1)
(initget 3)
(setq pkrobj (entsel "\n* Select line...*"))
(setq p1 (cdr (assoc 10 (entget (car pkrobj)))))
(setq p2 (cdr (assoc 11 (entget (car pkrobj)))))
(setvar "orthomode" 1)
(setvar "SNAPANG" (angle p1 p2))
;;(setq a (cadr pkrobj))
(setq a (mid p1 p2))
(initget 33)
(setvar "osmode" 0)
(setq b (getpoint a "\n* pick point...*"))
(setq pt (list a b))
(setq SS1 (ssget "F" pt '((0 . "LINE"))))
(command "line" a b "")
(setq ent1 (entlast))
(cond
(SS1
(repeat (sslength SS1)
(setq ent2 (cdr (assoc -1 (entget (ssname SS1 0)))))
(setq t1 (ARCH:GetIntersect ent1 ent2))
(setq ent3 (cdr (assoc -1 (entget (ssname SS1 1)))))
(setq t2 (ARCH:GetIntersect ent1 ent3))
)
)
)
(princ t1)
(princ t2)
(if ent1 (entdel ent1))
(ARCH:F_R-VAR)
(princ)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(princ)
|
--
Gary Fowler - Architect
gdfowler@hotmail.com
"Gary Fowler" <fowler@architettura-inc.com> wrote in message
news:425441f6$1_1@newsprd01...
| Quote: | Here is the routine I was wanting to modify. Jeff Mishler provided
the missing part. The routine inserts text centered between two
parallel lines and matches the line rotation. I am sure there
are easier ways to do this...but for now this is working. I still
have a lot of code cleanup to do...............
Thanks again Jeff.
| Code: |
(defun ARCH:CEN-BETWEEN-LIN2 (/ a b p1 p2 pt ent1 ent2 ent3 elist)
(if (not ARCH:GetIntersect)
(load (strcat ARCH#UTIF "ARCH_GET_INTERSECT")))
(defun CEN-BETWEEN-LIN-DOIT ()
(command "line" a b "")
(setq ent1 (entlast))
(cond (SS1
(repeat (sslength SS1)
(setq ent2 (cdr (assoc -1 (entget (ssname SS1 0)))))
(setq p1 (ARCH:GetIntersect ent1 ent2))
(setq ent3 (cdr (assoc -1 (entget (ssname SS1 1)))))
(setq p2 (ARCH:GetIntersect ent1 ent3)))))
(command "dist" "nea" p1 "per" p2)
(setq dist_1 (getvar "distance"))
(setq dist_2 (/ dist_1 2.0))
(setq x (/ (+ (car p1) (car p2)) 2))
(setq y (/ (+ (cadr p1) (cadr p2)) 2))
(setq z (/ (+ (caddr p1) (caddr p2)) 2))
(setq p3 (list x y z))
(command "offset" dist_2 ent2 p3 "")
(entdel ent1)
(princ))
(setvar "orthomode" 0)
(setvar "osmode" 0)
;;(initget 1)
(setq a (getpoint "\n* Draw Crossing Line *"))
(initget 33)
(setq b (getpoint a))
(setq pt (list a b))
(setq SS1 (ssget "F" pt '((0 . "LINE"))))
(cond
((or (= SS1 nil) (/= (sslength SS1) 2))
(ARCH:ALERT-E
"MsgBox \"
Selection Error Message
--------------------------------------------------------------------------------------------
Invalid Selection...either you selected nothing, a
double line <line on top of a line>, or a polyline.
If a double line, delete one, or if a polyline
change it to a line. Now you can try again...\""))
((CEN-BETWEEN-LIN-DOIT)))
(princ))
(defun c:WAL-2X6IT (/ ent entl startPt endPt angl)
;;(ARCH:F_S-VAR)
(setvar "osmode" 0)
(setvar "orthomode" 0)
(ARCH:CEN-BETWEEN-LIN2)
(command "change" "l" "" "p" "lt" "hidden" "c" "6" "")
;;(ARCH:CUSTOM_LAYERS-ANNO)
;;(ARCH:SET-NOTES)
(setq ITEM "2x6")
(setq entl (entlast))
(setq ent (entget (entlast))
startPt (cdr (assoc 10 ent))
endPt (cdr (assoc 11 ent))
midPt (mapcar '/ (mapcar '+ startPt endPt) '(2.0 2.0 2.0))
);;Jeff Mishler
(setvar "osmode" 0)
;;p3 from ARCH:CEN-BETWEEN-LIN2...global var
(if p3 (command "_.text" "j" "mc" p3 "" 0 ITEM))
(setvar "osmode" 0)
(setq ang (angle startPt endPt))
(if (and (<= ang 4.71239) (> ang 1.5708))
(setq ang (angle endPt startPt))
)
(setq angl (car (list (cons 50 ang))))
(setq N 0)
(setq TXT (ssget "L"))
(repeat (sslength TXT)
(setq
Elist
(subst
angl
(assoc 50 (entget (ssname TXT N)))
(entget (ssname TXT N))
)
)
(entmod Elist)
(entupd (ssname TXT N))
(setq N (+ N 1))
)
(entdel entl)
(setq p3 nil)
;;(ARCH:F_R-VAR)
(princ)
)
(c:WAL-2X6IT)
|
--
Gary Fowler - Architect
gdfowler@hotmail.com
"Gary Fowler" <fowler@architettura-inc.com> wrote in message
news:42543342$1_2@newsprd01...
Using (entlast), how would you get the two end points if the
object is a line? Also the midpoint?
Sorry, I'm brain dead right now.
(setq pnts (list (cdr (assoc 10 (entget (entlast))))(cdr (assoc 11
(entget
(entlast))))))?
--
Gary Fowler - Architect
gdfowler@hotmail.com
|
|
|
| Back to top |
|
 |
Adesu
Guest
|
Posted:
Thu Apr 07, 2005 4:54 am Post subject:
Re: Get points using entlast |
|
|
or
_$ (setq elast (entget (entlast)))
(setq sp (cdr (assoc 10 elast)))
(setq ep (cdr (assoc 11 elast)))
(setq mp (osnap sp "mid"))
((-1 . <Entity name: 15fe598>) (0 . "LINE") (330 . <Entity name: 15fe4f8>)
(5 . "6B") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (100 .
"AcDbLine") (10 0.0 0.0 0.0) (11 10.0 0.0 0.0) (210 0.0 0.0 1.0))
(0.0 0.0 0.0)
(10.0 0.0 0.0)
(5.0 0.0 0.0)
_$
Gary Fowler <fowler@architettura-inc.com> wrote in message
news:42543342$1_2@newsprd01...
| Quote: | Using (entlast), how would you get the two end points if the
object is a line? Also the midpoint?
Sorry, I'm brain dead right now.
(setq pnts (list (cdr (assoc 10 (entget (entlast))))(cdr (assoc 11 (entget
(entlast))))))?
--
Gary Fowler - Architect
gdfowler@hotmail.com
|
|
|
| Back to top |
|
 |
devitg
Guest
|
Posted:
Thu Apr 07, 2005 5:43 am Post subject:
Re: Get points using entlast |
|
|
Hi Ade , nice trick , could you explain how the "OSNAP" work in this case.
It do , but I do not know how. |
|
| Back to top |
|
 |
Jeff Mishler
Guest
|
Posted:
Thu Apr 07, 2005 6:33 am Post subject:
Re: Get points using entlast |
|
|
The lisp function Osnap takes a point as an argument and looks for an object
at that point....just as if you were selecting an object. However, that is
why I prefer the mathematical approach......if there is more than one object
at that point, depending on your aperture setting and the Object sort mode
you may not get the midpt of the desired object.
--
Jeff
check out www.cadvault.com
"devitg" <nospam@address.withheld> wrote in message
news:20604509.1112838228534.JavaMail.jive@jiveforum1.autodesk.com...
| Quote: | Hi Ade , nice trick , could you explain how the "OSNAP" work in this case.
It do , but I do not know how. |
|
|
| Back to top |
|
 |
|
|
|
|