Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

user coordinate system

66 views
Skip to first unread message

Coen van Dongen

unread,
Aug 2, 2001, 4:32:38 AM8/2/01
to
Hi everybody,

I'm trying to do a translation from world coordinates to a user coordinate
system but somewhere there seems to be a glitch, I've been staring blind at
it but maybe one of you sees the problem. I've basically copy pasted this
from the acad help and made some adjustments. The UCS is defines by two
angles that I get somewhere else and a basepoint, all of that info is stored
in global variables.

The angles are found like this:
moRowAngle = "a random angle"
moCollumnAngle = moRowAngle + 0.5 * PI

where PI is defined by: Atn(1) * 4

The error I'm getting is stating that the X and Y axis for the UCS are not
perpendicular.

Here is the code I'm using:

'=======================================================
Create WorldToGridUCS
On Error Resume Next
' This example creates a new UCS and finds the UCS matrix for it.
' It then creates a circle using WCS coordinates and
' transforms the circle for the UCS.

' Define a new UCS and turn on the UCS icon at the origin.
Dim origin(0 To 2) As Double
Dim xAxisPoint(0 To 2) As Double
Dim yAxisPoint(0 To 2) As Double
Dim TempPoint As Variant
Dim acLine1 As AcadLine
Dim acLine2 As AcadLine

'Set the 0 point of the coordinate system
origin(0) = moGridBasePoint(0): origin(1) = moGridBasePoint(1): origin(2) =
0

'Get a point on the X-axis
TempPoint = AcUtil.PolarPoint(moGridBasePoint, moRowAngle, 1)
xAxisPoint(0) = TempPoint(0): xAxisPoint(1) = TempPoint(1): xAxisPoint(2) =
0
Set acLine1 = ThisDrawing.ModelSpace.AddLine(origin, xAxisPoint)

'Get a point on the Y-axis
TempPoint = AcUtil.PolarPoint(moGridBasePoint, moCollumnAngle, 1)
yAxisPoint(0) = TempPoint(0): yAxisPoint(1) = TempPoint(1): yAxisPoint(2) =
0
Set acLine2 = ThisDrawing.ModelSpace.AddLine(origin, yAxisPoint)

moGridUCS = "WorldToGrid"

'If the coordinate system already exists then remove it from the collection
ThisDrawing.UserCoordinateSystems.Item(moGridUCS).Delete
If Err Then
'the coord system did not exist
Err.Clear
End If

Set moWorldToGridUCS = ThisDrawing.UserCoordinateSystems.Add(origin,
xAxisPoint, yAxisPoint, moGridUCS)
If Err Then
MsgBox Err.number & " : " & Err.Description
End If


'===================================================

Hope someone might now what the problem is. I've tried subtracting the 0.5
times PI instead of adding this had no effect.


Thilak

unread,
Aug 2, 2001, 5:27:04 AM8/2/01
to
Coen,

The code works fine.

Thilak


"Coen van Dongen" <Coenva...@hetnet.nl> wrote in message
news:FEF12E57699D6A43...@in.WebX.maYIadrTaRb...

Luc Morrissette

unread,
Aug 2, 2001, 7:50:15 AM8/2/01
to
Hi,

Can you explain what is wrong.

One thing i can see, i wrote lots of code using UCS's and creating the Axis
points at a distance of one was giving an error about the axis not being
perpendicular. If this is your problem put a big number in your polarpoint
function.

Luc Morrissette,
Flairbase inc.

"Coen van Dongen" <Coenva...@hetnet.nl> wrote in message
news:FEF12E57699D6A43...@in.WebX.maYIadrTaRb...

Coen van Dongen

unread,
Aug 2, 2001, 10:42:29 AM8/2/01
to
Hi All,

thanx for the input but the problem is located. It seems that using
polarpoint with a 0.5 * PI was just not accurate enough. Here's the trick
I'm using now:
Create axis point using polarpoint and x angle
Now draw a line between origin and x point and rotate that, do not use
PI*0.5 but the angletoreal function in the utilities give string "90" and
units acDegrees.
Take the endpoint of the rotated line and use that as a point on the y axis.

How's that for a bag o' tricks?

Still weird that it didn't just take the Atn(1)*4 pi value thing, first time
it didn't work for me.

Thanks a lot,
Coen

"Luc Morrissette" <lmorri...@flairbase.nospam.com> wrote in message
news:2583D790B9F077C0...@in.WebX.maYIadrTaRb...

0 new messages