trans help please?
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
trans help please?

 
Post new topic   Reply to topic    CADForums.net Forum Index -> Customization
Author Message
rgrainer
Guest





Posted: Wed Apr 06, 2005 8:09 am    Post subject: trans help please? Reply with quote

Hi all

When i have a block inserted at 0,0,0 in paperspace, the function below will
return the correct value for "stpoint". However if I move the block from
0,0,0 I get incorrect results. I have looked at the help files for the trans
function and they mention integer codes of 2 and 3 ....but I am unable to
get anywhere with it. if anyone could throw me a pointer....Thanks

Richard

;;;(defun c:doya ( / ent einfo stpoint endpoint)

(defun c:doya ( )

(setq ent (nentsel "\n Select Entity to copy:" ) )

(setq einfo (entget (car ent))

etype (cdr (assoc 0 einfo))

stpoint (trans (cdr (assoc 10 einfo))0 1)

endpoint (trans (cdr (assoc 11 einfo))0 1)

)

(princ stpoint)

(princ)

)

Back to top
Joe Burke
Guest





Posted: Wed Apr 06, 2005 3:15 pm    Post subject: Re: trans help please? Reply with quote

Richard,

How to deal with this depends... For instance, if the block containing the line is
only moved, and not rotated or scaled, that's one thing. Another consideration is
whether the line is nested just one level deep in the block. IOW, it's not nested in
a block inside the primary block.

If those conditions apply to your situation, then what you want to do is add the
block's insertion point to the start or end point returned. What you need to find is
the block's insertion point. Nentsel returns something like this with a block.

Command: (setq lst (nentsel))
Select object: (<Entity name: 7ef70bb8> (-543.304 -327.199 0.0) ((1.0 0.0 0.0)
(0.0 1.0 0.0) (0.0 0.0 1.0) (-817.293 -472.483 0.0)) (<Entity name: 7ef70c08>))

Get the line start point in OCS coordinates:
Command: (setq stpoint (cdr (assoc 10 (entget (car lst)))))
(119.126 119.085 0.0)

Get the block ename:
Command: (setq blk (last (last lst)))
<Entity name: 7ef70c08>

Get the block insertion point:
Command: (setq inspt (cdr (assoc 10 (entget blk))))
(-817.293 -472.483 0.0)

The start point transposed to WCS:
Command: (setq pt (mapcar '+ stpoint inspt))
(-698.168 -353.398 0.0)

Now if the block is moved and also rotated and/or scaled, you'd want a function to
deal with that. I'll post if you need it.

HTH,
Joe Burke


"rgrainer" <rgrainer@sbcglobal.net> wrote in message news:4253600f$1_3@newsprd01...
Quote:
Hi all

When i have a block inserted at 0,0,0 in paperspace, the function below will
return the correct value for "stpoint". However if I move the block from
0,0,0 I get incorrect results. I have looked at the help files for the trans
function and they mention integer codes of 2 and 3 ....but I am unable to
get anywhere with it. if anyone could throw me a pointer....Thanks

Richard

;;;(defun c:doya ( / ent einfo stpoint endpoint)

(defun c:doya ( )

(setq ent (nentsel "\n Select Entity to copy:" ) )

(setq einfo (entget (car ent))

etype (cdr (assoc 0 einfo))

stpoint (trans (cdr (assoc 10 einfo))0 1)

endpoint (trans (cdr (assoc 11 einfo))0 1)

)

(princ stpoint)

(princ)

)
Back to top
Richard
Guest





Posted: Thu Apr 07, 2005 12:26 am    Post subject: Re: trans help please? Reply with quote

thanks Joe
I had actually thought of the addition or subtraction of the insert point,
but was hoping that I didn't want to/have to go there. Thanks again for your
help
Richard

"Joe Burke" <joburke@hawaii.rr.com> wrote in message
news:4253c4ea_1@newsprd01...
Quote:
Richard,

How to deal with this depends... For instance, if the block containing the
line is
only moved, and not rotated or scaled, that's one thing. Another
consideration is
whether the line is nested just one level deep in the block. IOW, it's not
nested in
a block inside the primary block.

If those conditions apply to your situation, then what you want to do is
add the
block's insertion point to the start or end point returned. What you need
to find is
the block's insertion point. Nentsel returns something like this with a
block.

Command: (setq lst (nentsel))
Select object: (<Entity name: 7ef70bb8> (-543.304 -327.199 0.0) ((1.0 0.0
0.0)
(0.0 1.0 0.0) (0.0 0.0 1.0) (-817.293 -472.483 0.0)) (<Entity name:
7ef70c08>))

Get the line start point in OCS coordinates:
Command: (setq stpoint (cdr (assoc 10 (entget (car lst)))))
(119.126 119.085 0.0)

Get the block ename:
Command: (setq blk (last (last lst)))
Entity name: 7ef70c08

Get the block insertion point:
Command: (setq inspt (cdr (assoc 10 (entget blk))))
(-817.293 -472.483 0.0)

The start point transposed to WCS:
Command: (setq pt (mapcar '+ stpoint inspt))
(-698.168 -353.398 0.0)

Now if the block is moved and also rotated and/or scaled, you'd want a
function to
deal with that. I'll post if you need it.

HTH,
Joe Burke


"rgrainer" <rgrainer@sbcglobal.net> wrote in message
news:4253600f$1_3@newsprd01...
Hi all

When i have a block inserted at 0,0,0 in paperspace, the function below
will
return the correct value for "stpoint". However if I move the block from
0,0,0 I get incorrect results. I have looked at the help files for the
trans
function and they mention integer codes of 2 and 3 ....but I am unable
to
get anywhere with it. if anyone could throw me a pointer....Thanks

Richard

;;;(defun c:doya ( / ent einfo stpoint endpoint)

(defun c:doya ( )

(setq ent (nentsel "\n Select Entity to copy:" ) )

(setq einfo (entget (car ent))

etype (cdr (assoc 0 einfo))

stpoint (trans (cdr (assoc 10 einfo))0 1)

endpoint (trans (cdr (assoc 11 einfo))0 1)

)

(princ stpoint)

(princ)

)



Back to top
Luis Esquivel
Guest





Posted: Thu Apr 07, 2005 12:56 am    Post subject: Re: trans help please? Reply with quote

Are you the one I know?.... from LA in one presentation I did related about
vlisp reactors?

LE.

"rgrainer" <rgrainer@sbcglobal.net> wrote in message
news:4253600f$1_3@newsprd01...
Quote:
Hi all

When i have a block inserted at 0,0,0 in paperspace, the function below
will
return the correct value for "stpoint". However if I move the block from
0,0,0 I get incorrect results. I have looked at the help files for the
trans
function and they mention integer codes of 2 and 3 ....but I am unable to
get anywhere with it. if anyone could throw me a pointer....Thanks

Richard

;;;(defun c:doya ( / ent einfo stpoint endpoint)

(defun c:doya ( )

(setq ent (nentsel "\n Select Entity to copy:" ) )

(setq einfo (entget (car ent))

etype (cdr (assoc 0 einfo))

stpoint (trans (cdr (assoc 10 einfo))0 1)

endpoint (trans (cdr (assoc 11 einfo))0 1)

)

(princ stpoint)

(princ)

)



Back to top
rgrainer
Guest





Posted: Thu Apr 07, 2005 8:09 am    Post subject: Re: trans help please? Reply with quote

Hi Luis
Yes I am he (in both post Richard & rgrainer) from the presentation in LA
how are you?...I've seen some of your posts from time to time.
I have relocated jobs recently. I hope is all is well with you and your
family
Richard
"Luis Esquivel" <nospam@address.withheld> wrote in message
news:42544ce8$1_2@newsprd01...
Quote:
Are you the one I know?.... from LA in one presentation I did related
about
vlisp reactors?

LE.

"rgrainer" <rgrainer@sbcglobal.net> wrote in message
news:4253600f$1_3@newsprd01...
Hi all

When i have a block inserted at 0,0,0 in paperspace, the function below
will
return the correct value for "stpoint". However if I move the block from
0,0,0 I get incorrect results. I have looked at the help files for the
trans
function and they mention integer codes of 2 and 3 ....but I am unable
to
get anywhere with it. if anyone could throw me a pointer....Thanks

Richard

;;;(defun c:doya ( / ent einfo stpoint endpoint)

(defun c:doya ( )

(setq ent (nentsel "\n Select Entity to copy:" ) )

(setq einfo (entget (car ent))

etype (cdr (assoc 0 einfo))

stpoint (trans (cdr (assoc 10 einfo))0 1)

endpoint (trans (cdr (assoc 11 einfo))0 1)

)

(princ stpoint)

(princ)

)





Back to top
Luis Esquivel
Guest





Posted: Thu Apr 07, 2005 8:42 am    Post subject: Re: trans help please? Reply with quote

Hi,

Glad to see you here....

Everything is just fine... doing the same, are you still in LA?

I'm going to sent to you a module I did for transformations, so you can give it a try.... Joe and James have done also their own approach's, so maybe tomorrow you will get more help on this.

What is your e-mail?

Good night,
Luis.
Back to top
rgrainer
Guest





Posted: Thu Apr 07, 2005 9:09 am    Post subject: Re: trans help please? Reply with quote

Wow
thanks so much. yes still in LA. I have a sheet that is a block (not 0,0,0)
and I want to be able to offset a line after reading a line entity from the
block.
that's what this whole thing is about. Joes idea was good I was just hoping
for an easier way.
my email is rgrainer@sbc nospam= global=.net
(just take out the npspam and equals sign)
Good Night

"Luis Esquivel" <nospam@address.withheld> wrote in message
news:23568627.1112848967785.JavaMail.jive@jiveforum2.autodesk.com...
Quote:
Hi,

Glad to see you here....

Everything is just fine... doing the same, are you still in LA?

I'm going to sent to you a module I did for transformations, so you can
give it a try.... Joe and James have done also their own approach's, so

maybe tomorrow you will get more help on this.
Quote:

What is your e-mail?

Good night,
Luis.
Back to top
Joe Burke
Guest





Posted: Thu Apr 07, 2005 4:00 pm    Post subject: Re: trans help please? Reply with quote

Richard,

You're welcome.

I might as well post this since you might need it. Or maybe you'll find it easier
with these as toolbox functions.

The @PTrans function deals with the fact the block may be rotated and/or scaled, as
well as moved. The nested block consideration still applies.

Regarding, "thought of the addition or subtraction..." it's always addition going
from OCS to WCS.

Joe Burke

Code:

;; Function based on Doug Wilson's Transpose function
;; to convert a 4x3 matrix from (nentsel)
;; to a 4x4 matrix from (nentselp)
;; (c)2002, John F. Uhden, Cadlantic (05-18-02)
(defun 4x3->4x4 (matrix)
  (append (apply 'mapcar (cons 'list matrix))'((0.0 0.0 0.0 1.0)))
)

;; Function to transform a point from either:
;;   the MCS of an entity selected by (nentsel), or
;;   the OCS of an entity selected by (nentselp)
;;   to the WCS.
;; Given:
;;   P = point to transform (list of 3 reals)
;;   M = transormation matrix:
;;       either 4x3 as returned by (nentsel)
;;       or 4x4 as returned by (nentselp)
;; (c)2003, John F. Uhden, Cadlantic (08-03-03)
(defun @PTrans (P M)
  (if (= (length P) 2)
     (setq P (append P '(0.0 1.0)))
     (setq P (append P '(1.0)))
  )
  (if (= (length (car M)) 3)
    (setq M (4x3->4x4 M))
  )
  (mapcar
    (function (lambda (x)(apply '+ x)))
    (list (mapcar '* P (car M))
          (mapcar '* P (cadr M))
          (mapcar '* P (caddr M))
    )
  )
)


Quote:
thanks Joe
I had actually thought of the addition or subtraction of the insert point,
but was hoping that I didn't want to/have to go there. Thanks again for your
help
Richard
Back to top
 
Post new topic   Reply to topic    CADForums.net Forum Index -> Customization All times are GMT
Page 1 of 1

 
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
Powered by phpBB