Filtering using entity name / handle
CADForums.net Forum Index CADForums.net
Discussion of AutoCAD and other CAD software.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web cadforums.net
Filtering using entity name / handle
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CADForums.net Forum Index -> Customization
Author Message
Joe Burke
Guest





Posted: Wed Jan 05, 2005 8:00 pm    Post subject: Re: Filtering using entity name / handle Reply with quote

James,

Total tangent as follows.

The reason the bounding box approach came to mind is I've been playing with them
recently when selecting an object in an xref.

Example:
(setq elst (nenselp "\nSelect object in xref: "))

How do I indicate to the user an object in an xref was selected, assuming I don't
want to copy the object into the active file? Which would let me highlight it. One
solution, draw the object's bounding box using grdraw. I know you know this can be
complicated stuff given an object which may be nested in blocks x levels deep within
the xref block.

I've worked all that stuff out recently based on the same ObjMartix and
InverseObjMatrix functions I posted previously. What I didn't have before was a
reliable transpose point function based on those functions. I'll post if you are
interested. BTW, I took your advice. The TransPt function asks for a point, a list of
blocks (don't ask until you see it) and "from" and "to" arguments like the trans
function. It works for me very nicely that way.

Thanks for the idea based on code you posted elsewhere.

Joe Burke



Quote:
Joe Burke _originally_ wrote: "Just for fun... " ;) Don't worry, that's
how I took it. But it did get me thinking.

Believe it or not, I don't think it had even occured to me to use the
bounding box to generate a selection window. I think my existing routine
uses a somewhat arbitrary crossing window (yeah, it's the zoom around kind).
But for merging/welding, the crossing window may still be needed for this
approach. For non-crossing windows, I agree about making the window a bit
larger, especially with the potential loss of precision through graphic
selection.

I appreciate the thoughts.

James


Back to top
James Allen
Guest





Posted: Thu Jan 06, 2005 5:03 am    Post subject: Re: Filtering using entity name / handle Reply with quote

I like tangents. Interesting! And kinda scary. Among other things, I am
basically messing with the same thing right now (xref-nested
"highlighting"), but took the copy-the-object route. I started with a very
careful re-evaluation of my error handling, and so far I haven't ended up
with left over copied objects... Here's hoping. I am interested in seeing
your work, though it may be a bit before I can give it a worthwhile look
over (pretty erratic workload right now). And you're quite welcome.

James


"Joe Burke" <joburke@hawaii.rr.com> wrote in message
news:41dc012e$1_3@newsprd01...
Quote:
James,

Total tangent as follows.

The reason the bounding box approach came to mind is I've been playing
with them
recently when selecting an object in an xref.

Example:
(setq elst (nenselp "\nSelect object in xref: "))

How do I indicate to the user an object in an xref was selected, assuming
I don't
want to copy the object into the active file? Which would let me highlight
it. One
solution, draw the object's bounding box using grdraw. I know you know
this can be
complicated stuff given an object which may be nested in blocks x levels
deep within
the xref block.

I've worked all that stuff out recently based on the same ObjMartix and
InverseObjMatrix functions I posted previously. What I didn't have before
was a
reliable transpose point function based on those functions. I'll post if
you are
interested. BTW, I took your advice. The TransPt function asks for a
point, a list of
blocks (don't ask until you see it) and "from" and "to" arguments like the
trans
function. It works for me very nicely that way.

Thanks for the idea based on code you posted elsewhere.

Joe Burke
Back to top
Joe Burke
Guest





Posted: Thu Jan 06, 2005 5:33 pm    Post subject: Re: Filtering using entity name / handle Reply with quote

James,

Here's the matrix functions again. They are not changed, other than comments, from
what I posted last.

I don't recall if I posted the TransPt function before. If I did, it didn't deal with
deep nested blocks correctly. After beating on this version hard, I'm confident it
does what it should.

Agreed, when a program specifically prompts for select something in an xref, it
should provide some visual feedback when the selection is successful. Copying the
object so it can be highlighted is one way to do it. But as you know, doing that
right is a bit involved code-wise. That's why I was playing with the other
possibility, simply draw the object's bounding box. Of course for that I need all the
following functions. So doing the bounding box right isn't exactly easy either.

BTW, I don't have a clue on how to modify the matrix functions so they return the
same matrix as nentselp when the block ref passed had a normal other than (0 0 1).
Any help on that point would be much appreciated.

Regards
Joe

;; Apply a transformation matrix to a vector by Vladimir Nesterovsky
(defun mxv (m v)
(mapcar '(lambda (row) (apply '+ (mapcar '* row v))) m)
) ;end

;; Multiply two matrices by Vladimir Nesterovsky
(defun mxm (m q / qt)
(setq qt (apply 'mapcar (cons 'list q)))
(mapcar '(lambda (mrow) (mxv qt mrow)) m)
) ;end

;; By Joe Burke with thanks to Larry Leuallen and John Uhden.
;; Returns the same block transformation matrix as nentselp,
;; except when the normal is something other than (0 0 1).
;; Haven't figured that one out yet.
;; argument vobj: a block reference ename or vla-object
(defun ObjMatrix ( vobj / ang inspt xsf ysf zxf
sclmatrix rotmatrix movmatrix resmatrix )
(if (= (type vobj) 'ENAME)
(setq vobj (vlax-ename->vla-object vobj))
)
(and
(= "AcDbBlockReference" (vlax-get vobj 'ObjectName))
(setq ang (vlax-get vobj 'Rotation))
(setq inspt (vlax-get vobj 'InsertionPoint))
(setq xsf (vlax-get vobj 'XScaleFactor))
(setq ysf (vlax-get vobj 'YScaleFactor))
(setq zsf (vlax-get vobj 'ZScaleFactor))
;test for non-uniformly scaled block
(equal (abs xsf) (abs ysf) 1e-8)
(equal (abs ysf) (abs zsf) 1e-8)
(setq sclmatrix
(list
(list xsf 0 0 0)
(list 0 ysf 0 0)
(list 0 0 zsf 0)
(list 0 0 0 1)
)
)
;; if block is mirrored only X, Y or Z
;; else, all other mirrored combinations including none
(if
(or
(and (minusp xsf) (not (minusp ysf)) (not (minusp zsf)))
(and (not (minusp xsf)) (minusp ysf) (not (minusp zsf)))
(and (not (minusp xsf)) (not (minusp ysf)) (minusp zsf))
)
(setq rotmatrix
(list
(list (cos ang) (sin ang) 0 0)
(list (- (sin ang)) (cos ang) 0 0)
(list 0 0 1 0)
(list 0 0 0 1)
)
)
(setq rotmatrix
(list
(list (cos ang) (- (sin ang)) 0 0)
(list (sin ang) (cos ang) 0 0)
(list 0 0 1 0)
(list 0 0 0 1)
)
)
)
(setq movmatrix
(list
(list 1 0 0 (car inspt))
(list 0 1 0 (cadr inspt))
(list 0 0 1 (caddr inspt))
(list 0 0 0 1)
)
)
(setq resmatrix (mxm movmatrix (mxm sclmatrix rotmatrix)))
) ;and
resmatrix
) ;end

;-------------------------------------------------------------------
;; returns an inverse matrix
;; argument vobj: a block reference ename or vla-object
(defun InverseObjMatrix ( vobj / ang inspt xsf ysf zxf
sclmatrix rotmatrix movmatrix resmatrix )
(if (= (type vobj) 'ENAME)
(setq vobj (vlax-ename->vla-object vobj))
)
(and
(= "AcDbBlockReference" (vlax-get vobj 'ObjectName))
(setq ang (- (vlax-get vobj 'Rotation)))
(setq inspt (mapcar '- (vlax-get vobj 'InsertionPoint)))
(setq xsf (/ 1.0 (vlax-get vobj 'XScaleFactor)))
(setq ysf (/ 1.0 (vlax-get vobj 'YScaleFactor)))
(setq zsf (/ 1.0 (vlax-get vobj 'ZScaleFactor)))
(equal (abs xsf) (abs ysf) 1e-8)
(equal (abs ysf) (abs zsf) 1e-8)
(setq sclmatrix
(list
(list xsf 0 0 0)
(list 0 ysf 0 0)
(list 0 0 zsf 0)
(list 0 0 0 1)
)
)
(if
(or
(and (minusp xsf) (not (minusp ysf)) (not (minusp zsf)))
(and (not (minusp xsf)) (minusp ysf) (not (minusp zsf)))
(and (not (minusp xsf)) (not (minusp ysf)) (minusp zsf))
)
(setq rotmatrix
(list
(list (cos ang) (sin ang) 0 0)
(list (- (sin ang)) (cos ang) 0 0)
(list 0 0 1 0)
(list 0 0 0 1)
)
)
(setq rotmatrix
(list
(list (cos ang) (- (sin ang)) 0 0)
(list (sin ang) (cos ang) 0 0)
(list 0 0 1 0)
(list 0 0 0 1)
)
)
)
(setq movmatrix
(list
(list 1 0 0 (car inspt))
(list 0 1 0 (cadr inspt))
(list 0 0 1 (caddr inspt))
(list 0 0 0 1)
)
)
(setq resmatrix (mxm rotmatrix (mxm sclmatrix movmatrix)))
) ;and
resmatrix
) ;end

;-------------------------------------------------------------------
;; supports blocks nested at any level
;; returns a transformed point
;; arguments:
;; pt - point to transform
;; blklst - typically a list of enames as returned
;; by the last list from nentsel or nentselp
;; FROM and TO similar to trans: WCS = 0, UCS = 1 and OCS = 2
;; examples: (TransPt point blocklist 1 2) UCS > OCS
;; (TransPt point blocklist 2 0) OCS > WCS
(defun TransPt ( pt blklst from to / ptmatrix matrix matrixlst res )
(and
(or
(= 3 (length pt))
(setq pt (append pt '(0.0)))
)
(or
(or (= from 0) (= from 2))
(setq pt (trans pt 1 0))
)
(if (or (= to 0) (= to 1))
(setq matrixlst (mapcar 'ObjMatrix blklst)) ;to WCS or UCS
(setq matrixlst (reverse (mapcar 'InverseObjMatrix blklst))) ;to OCS
)
;test for any nil matrix caused by a non-uniformly scaled block
(apply 'and matrixlst)
(setq matrix (car matrixlst))
(if (> (length matrixlst) 1)
(repeat (1- (length matrixlst))
(setq matrix (mxm (cadr matrixlst) matrix))
(setq matrixlst (cdr matrixlst))
)
T
)
(setq ptmatrix
(list
(list 1 0 0 (car pt))
(list 0 1 0 (cadr pt))
(list 0 0 1 (caddr pt))
(list 0 0 0 1)
)
)
(setq matrix (mxm matrix ptmatrix))
(setq res
(list
(last (car matrix))
(last (cadr matrix))
(last (caddr matrix))
)
)
(or
(or (= to 0) (= to 2))
(setq res (trans res 0 1))
)
) ;and
res
) ;end


Quote:
I like tangents. Interesting! And kinda scary. Among other things, I am
basically messing with the same thing right now (xref-nested
"highlighting"), but took the copy-the-object route. I started with a very
careful re-evaluation of my error handling, and so far I haven't ended up
with left over copied objects... Here's hoping. I am interested in seeing
your work, though it may be a bit before I can give it a worthwhile look
over (pretty erratic workload right now). And you're quite welcome.

James


Back to top
James Allen
Guest





Posted: Thu Jan 06, 2005 7:56 pm    Post subject: Re: Filtering using entity name / handle Reply with quote

Joe, I'd love to help. Will look over your functions as soon as I have a
chance.

In the meantime, reviewing the GetNMatrix and GetOMatrix functions that I
posted in BlockSwap.lsp before ( news:41632e38_1@newsprd01 ) may give you a
head start on me. If I remember right, the GetBlockTMatrix function (which
uses the others) returns exactly the same matrix as nentselp, given the
right bit code.

Fundamentally, a normal transform is the same as a rotation transform. A
general orientation matrix consists of projection of your unit direction
vector onto the various axes. In the AutoCAD world, "rotation" is generally
assumed to be about the z-axis so projection of this unit direction vector
onto the z-axis is zero.

As well as general transformation issues, I would be interested in
specifically discussing the nested highlighting more. It seems to me that
the difference in amount of code would be negligible, as most of the
overhead involves transformations which are required in either case. I will
be out of town for a few days starting tomorrow though. Should we start a
new thread?

James


"Joe Burke" <joburke@hawaii.rr.com> wrote in message
news:41dd305d_3@newsprd01...
Quote:
James,

Here's the matrix functions again. They are not changed, other than
comments, from
what I posted last.

I don't recall if I posted the TransPt function before. If I did, it
didn't deal with
deep nested blocks correctly. After beating on this version hard, I'm
confident it
does what it should.

Agreed, when a program specifically prompts for select something in an
xref, it
should provide some visual feedback when the selection is successful.
Copying the
object so it can be highlighted is one way to do it. But as you know,
doing that
right is a bit involved code-wise. That's why I was playing with the other
possibility, simply draw the object's bounding box. Of course for that I
need all the
following functions. So doing the bounding box right isn't exactly easy
either.

BTW, I don't have a clue on how to modify the matrix functions so they
return the
same matrix as nentselp when the block ref passed had a normal other than
(0 0 1).
Any help on that point would be much appreciated.

Regards
Joe
Back to top
Joe Burke
Guest





Posted: Fri Jan 07, 2005 4:44 am    Post subject: Re: Filtering using entity name / handle Reply with quote

James,

Yes, start a new thread when you have some time. I'll keep an eye out.

Regarding BlockSwap, I don't think I've seen it before. Will study and thanks. I did
save and study the code you posted in the move block insertion point thread.

I tried a couple months ago to fix the matrix functions so they would handle a
non-standard normal vector. Gave up, frustrated. Assuming the solution is just
another matrix multiplication, the part I couldn't figure out is where to put a
normal matrix in the multiplication sequence.

I agree regarding the amount of code needed to copy an object from an xref vs.
drawing its bounding box. And hey, who cares how much it takes if you have reliable
code in hand. But then there is an issue, in my mind anyway, about not altering a
drawing if you don't have to, in order to accomplish a certain task. For instance, if
the object isn't copied, there's no concern about the baggage it might bring along. A
copied block might add... well, you know.

Not forgetting the fact, the bounding box idea isn't as cosmetically pleasing as copy
and highlight.

Have a good trip.

Joe

Quote:
Joe, I'd love to help. Will look over your functions as soon as I have a
chance.

In the meantime, reviewing the GetNMatrix and GetOMatrix functions that I
posted in BlockSwap.lsp before ( news:41632e38_1@newsprd01 ) may give you a
head start on me. If I remember right, the GetBlockTMatrix function (which
uses the others) returns exactly the same matrix as nentselp, given the
right bit code.

Fundamentally, a normal transform is the same as a rotation transform. A
general orientation matrix consists of projection of your unit direction
vector onto the various axes. In the AutoCAD world, "rotation" is generally
assumed to be about the z-axis so projection of this unit direction vector
onto the z-axis is zero.

As well as general transformation issues, I would be interested in
specifically discussing the nested highlighting more. It seems to me that
the difference in amount of code would be negligible, as most of the
overhead involves transformations which are required in either case. I will
be out of town for a few days starting tomorrow though. Should we start a
new thread?

James
Back to top
 
Post new topic   Reply to topic    CADForums.net Forum Index -> Customization All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Windows Server DSP VoIP Electronics New Topics
Contact Us
Powered by phpBB