Author Topic: Need help to establish OCS and "arbitrary axis algorithm" Visual  (Read 2449 times)

0 Members and 1 Guest are viewing this topic.

Shay Gaghe

  • Newt
  • Posts: 89
Hi

the docs describe OCS like this

Quote
To save space in the drawing database (and in the DXF file), the points associated with each entity are expressed in terms of the entity's own object coordinate system (OCS). With OCS, the only additional information needed to describe the entity's position in 3D space are the 3D vector describing the Z axis of the OCS and the elevation value.
For a given Z axis (or extrusion) direction, there are an infinite number of coordinate systems, defined by translating the origin in 3D space and by rotating the X and Y axes around the Z axis. However, for the same Z axis direction, there is only one OCS. It has the following properties:
Its origin coincides with the WCS origin.
The orientation of the X and Y axes within the XY plane is calculated in an arbitrary but consistent manner. AutoCAD performs this calculation using the arbitrary axis algorithm (see Arbitrary Axis Algorithm).

Once AutoCAD has established the OCS for a given entity, the OCS works as follows: The elevation value stored with an entity indicates how far to shift the XY plane along the Z axis (from the WCS origin) to make it coincide with the plane that contains the entity. How much of this is the user-defined elevation is unimportant.
Any 2D points entered through the UCS are transformed into the corresponding 2D points in the OCS, which is shifted and rotated with respect to the UCS.


i visulze that proccess like that :

User adopt new UCS and draw a circle, than the circle points were translated to OCS using the elevation and Z vectror.



am i right?

Thanks
Shay

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Need help to establish OCS and "arbitrary axis algorithm" Visual
« Reply #1 on: August 09, 2014, 08:08:40 AM »
That stuff make my head hurt. Gile & Lee Mac have a good understanding of it.

Take a look at these threads
http://www.theswamp.org/index.php?topic=13526.0
http://www.theswamp.org/index.php?topic=31802.0
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Need help to establish OCS and "arbitrary axis algorithm" Visual
« Reply #2 on: August 11, 2014, 02:07:08 PM »
Here is some code that will insert a given block 'on' the current UCS (color red), the corresponding OCS(color green) and the WCS (color white). Make sure to use a block containing some elements with the color ByBlock.
Note: I use BricsCAD instead of AutoCAD.

Code: [Select]
(defun c:CS_Insert ( / name UcsZDir)
  (if (tblobjname "block" (setq name (getstring T "\nValid block name: ")))
    (progn
      (setq UcsZDir (trans '(0.0 0.0 1.0) 1 0 T))
      ; Current UCS:
      (entmake
        (list
          '(0 . "INSERT")
          '(8 . "0")
          '(62 . 1) ; Red.
          (cons 2 name)
          (cons 10 (trans '(0.0 0.0 0.0) 1 UcsZDir))
          '(41 . 1.0)
          '(42 . 1.0)
          '(43 . 1.0)
          (cons 50 (angle '(0.0 0.0 0.0) (trans '(1.0 0.0 0.0) 1 UcsZDir T)))
          (cons 210 UcsZDir)
        )
      )
      ; OCS:
      (entmake
        (list
          '(0 . "INSERT")
          '(8 . "0")
          '(62 . 3) ; Green.
          (cons 2 name)
          '(10 0.0 0.0 0.0)
          '(41 . 1.0)
          '(42 . 1.0)
          '(43 . 1.0)
          '(50 . 0.0)
          (cons 210 UcsZDir)
        )
      )
      ; WCS:
      (entmake
        (list
          '(0 . "INSERT")
          '(8 . "0")
          '(62 . 7) ; White/black.
          (cons 2 name)
          '(10 0.0 0.0 0.0)
          '(41 . 1.0)
          '(42 . 1.0)
          '(43 . 1.0)
          '(50 . 0.0)
          '(210 0.0 0.0 1.0)
        )
      )
    )
  )
  (princ)
)
« Last Edit: August 11, 2014, 02:18:05 PM by roy_043 »