TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: kruuger on April 30, 2011, 07:45:16 PM
-
Hello,
like in subject. for now i got this:
; ============================================================ ;
; Get block attribute insertion point ;
; En - object ename ;
; Tag [STR] - attribute tag ;
; ============================================================ ;
(defun kr:MVP_GetAttributeInsertionPoint (En Tag / EN PT)
(while
(and
(setq EN (entnext (cdr (assoc -1 (entget En)))))
(setq PT (cdr (assoc 10 (entget EN))))
(/= Tag (cdr (assoc 2 (entget EN))))
)
T
)
PT
)
what should be modified to work it any UCS (now return correct point only for WCS)
thanks
kruuger
-
Have a look at these post by Gile
Block UCS (http://www.theswamp.org/index.php?action=search2;params=YWR2YW5jZWR8J3wxfCJ8dXNlcnNwZWN8J3xnaWxlfCJ8YnJkfCd8MnwifHNob3dfY29tcGxldGV8J3x8InxzdWJqZWN0X29ubHl8J3x8Inxzb3J0X2RpcnwnfGRlc2N8Inxzb3J0fCd8cmVsZXZhbmNlfCJ8c2VhcmNofCd8YmxvY2sgdWNzIA==)
-
Maybe something along these lines:
(defun GetAttribInsertion ( block tag / att elist ) (setq att block tag (strcase tag))
(while
(and
(eq "ATTRIB"
(cdr
(assoc 0
(setq elist
(entget (setq att (entnext att)))
)
)
)
)
(not (eq tag (strcase (cdr (assoc 2 elist)))))
)
)
(if (eq "ATTRIB" (cdr (assoc 0 elist)))
(trans
(cdr
(assoc
(if
(and
(= 0 (cdr (assoc 72 elist)))
(= 0 (cdr (assoc 73 elist)))
)
10 11
)
elist
)
)
att 0
)
)
)
Returns a point in WCS if Tag is present.
-
thank CAB for links. i found this:
http://www.theswamp.org/index.php?topic=26591.msg320739#msg320739
it seams to do the job i want:
(TransNested ((kr:MVP_GetAttributeInsertionPoint En Tag) En 1 0))
Lee,
your code return same point as mine ? right ? but your code is more elegant :)
thanks
kruuger
-
Lee,
your code return same point as mine ? right ? but your code is more elegant :)
I thought mine would return the insertion point of the attribute in WCS independent of the UCS settings - does it not?
-
Lee,
your code return same point as mine ? right ? but your code is more elegant :)
I thought mine would return the insertion point of the attribute in WCS independent of the UCS settings - does it not?
Lee your code return the same point as mine (incorect).
as i mentioned before Gile's code works perfect.
See my test function with block.
kruuger
-
Kruuger,
I haven't looked at your drawing but from your code I immediately notice you are using a command call to test the point returned. I would remind you that as stated, my code returns a point in WCS, whereas points supplied to a command are affected by the setting of the UCS.
Perhaps use this to test:
(defun c:test ( / e p )
(if
(and
(setq e (car (entsel "\nSelect Block: ")))
(eq "INSERT" (cdr (assoc 0 (entget e))))
(= 1 (cdr (assoc 66 (entget e))))
(setq a (getstring "\nSpecify Attribute Tag: "))
(setq p (GetAttribInsertion e a))
)
(entmakex (list (cons 0 "POINT") (cons 10 p)))
)
(princ)
)
I believe Gile's code would only be required for entities that make up the block definition (to transform these relative to the selected Insert) - not attributes (as these are already defined relative to the Insert). But maybe I am wrong.
-
.... whereas points supplied to a command are affected by the setting of the UCS...
aaa....i forgot about that :ugly:
with entmakex my code also is correct. my mistake :oops:
thanks for help and explanation
kruuger
-
with entmakex my code also is correct. my mistake :oops:
I believe your code will be incorrect for Attribs defined in a plane which differs from the WCS plane, since Attribs are defined relative to their OCS and Points relative to the WCS.
-
with entmakex my code also is correct. my mistake :oops:
I believe your code will be incorrect for Attribs defined in a plane which differs from the WCS plane, since Attribs are defined relative to their OCS and Points relative to the WCS.
seams to work for me. you can try my sample
kruuger
-
seams to work for me. you can try my sample
It is not correct in my testing - try inserting a block with normal of '(-1. 0. 0.) for example, then try the different codes.
Lee
-
seams to work for me. you can try my sample
It is not correct in my testing - try inserting a block with normal of '(-1. 0. 0.) for example, then try the different codes.
Lee
now i understood...for me "any ucs" means, 2d ucs like: north , east etc. (no 3d)
my function work only with normal '(0. 0. 1.), yours with any.
thanks for lesson Lee
kruuger
-
You're welome Kruuger :-)