Author Topic: Another UCS question  (Read 1570 times)

0 Members and 1 Guest are viewing this topic.

hermanm

  • Guest
Another UCS question
« on: July 08, 2010, 01:38:45 PM »
Is it possible to determine programmatically the origin of an unnamed (current) UCS?

Or, in other words, how is it possible to determine if we are in WCS?

If the UCS is named, we can fetch its info from the UCS Collection, but no entry exists if the current UCS has not been named.

For a rotation, we can use the UCSXDIR & UCSYDIR system variables, but if the UCS is only displaced in X-Y from WCS (no rotation), these will be identical to values for WCS.

The only way method which occurs to me is:

Code: [Select]
Command: (trans '(0 0 0) 1 0)
(3.67394 5.66237 0.0)

Which will return (0.0 0.0 0.0) if the origin is WCS origin.
Then check for rotation using UCSXDIR or UCSYDIR.

I guess this works.. I was looking for some slick COM method, but do not find one.
Anyone else?

Lee Mac

  • Seagull
  • Posts: 12927
  • London, England
Re: Another UCS question
« Reply #1 on: July 08, 2010, 01:43:01 PM »
From what I have learnt, the origin in terms of WCS can be found using:

Code: [Select]
(trans '(0. 0. 0.) 1 (trans '(0. 0. 1.) 1 0 t))

Which I think is the same as (getvar 'UCSORG)

As for testing for World, how about

Code: [Select]
(= 1 (getvar 'WORLDUCS))

Lee

gile

  • Gator
  • Posts: 2520
  • Marseille, France
Re: Another UCS question
« Reply #2 on: July 08, 2010, 01:57:23 PM »
Not exactly Lee.

(trans '(0. 0. 0.) 1 (trans '(0. 0. 1.) 1 0 t)) returns the samething as (getvar 'UCSORG) only when (trans '(0. 0. 1.) 1 0 t) returns (0.0 0.0 1.0) IOW only when the UCS plane is parallel to the WCS one.
In this case (trans '(0. 0. 0.) 1 (trans '(0. 0. 1.) 1 0 t)) is the same as (trans '(0. 0. 0.) 1 0) and this last expression always returns the same as (getvar 'UCSORG).

Speaking English as a French Frog

Lee Mac

  • Seagull
  • Posts: 12927
  • London, England
Re: Another UCS question
« Reply #3 on: July 08, 2010, 01:59:45 PM »
Ah I see - many thanks for that clarification Gile  :-)

So is

Code: [Select]
(trans '(0. 0. 0.) 1 (trans '(0. 0. 1.) 1 0 t))
Correct to use to account for UCS planes not parallel to the WCS plane?

gile

  • Gator
  • Posts: 2520
  • Marseille, France
Re: Another UCS question
« Reply #4 on: July 08, 2010, 03:21:55 PM »
No,
It won't return the same as UCSORG.

(trans '(0. 0. 1.) 1 0 t) returns a vector and a coordinate system (CS) can be built around this using the arbitrary algorythm (see advanced topics in the DXF Reference). This is the the way used by AutoCAD to define OCSs.
But this CS souldn't be the same as the UCS: it's origin is always 0, 0, 0 and the X and Y axis.
See this thread.
Speaking English as a French Frog