Message 1 of 12
I'm not understanding ucs method!?!

Not applicable
03-03-2003
03:13 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Can anywone explain the following behaviour to me?
It does not seem to work as I would expect. (that's what I get for having
expectations!)
I start with blank dwg
create a box(3dsolid) at 0,0,0
W = 3, L = 2, H = 4
orbit to sw iso more or less to see the box and ucs icon
'...heres a function to change to 'right side ucs'
'...it should 'supposedly' change the current ucs (from world or ?) to right
side ucs
'... it then returns the new ucs object
Function UcR() As AcadUCS
Dim Neworigin(0 To 2) As Double
ThisDrawing.Utility.GetPoint Neworigin, "Pick a point, El Cadilator!"
'pick the lower right corner of box (world coord: 2,0,0)
Dim xAxisPoint(2) As Double
Dim YAxisPoint(2) As Double
Dim ucsObjR As AcadUCS
xAxisPoint(0) = Neworigin(0): xAxisPoint(1) = Neworigin(1) + 1:
xAxisPoint(2) = Neworigin(2)
YAxisPoint(0) = Neworigin(0): YAxisPoint(1) = Neworigin(1):
YAxisPoint(2) = Neworigin(2) + 1
Set ucsObjR = ThisDrawing.UserCoordinateSystems.Add(Neworigin,
xAxisPoint, YAxisPoint, "UCSRIGHT")
ThisDrawing.ActiveUCS = ucsObjR
'when the ucs origin did not change to the origin I sent to the add method
'i thought I could force it to move to the correct point with the next line
but it did no good....
'ucsObj.origin = Neworigin
'that line has no effect...(that I can see)
ThisDrawing.ActiveViewport.UCSIconOn = True
ThisDrawing.ActiveViewport.UCSIconAtOrigin = True
'the next line seems like a bug to me....
'ThisDrawing.ActiveViewport = ThisDrawing.ActiveViewport
' I would expect that command to move the ucs icon to the point I picked for
new origin, instead it changes the ucs to world and zooms to a previous view
'if I comment out that line, the ucs changes to right side but the ucs icon
does not move to world 2,0,0 as it should according to the function above,
but rather it stays at 0,0,0 and just rotates to the right side direction.
...what am I not understanding???
Set UcR = ucsObjR
End Function
...here's a sub to test the above
Sub UCSMatrixTest2()
' Define a new UCS and turn on the UCS icon at the origin.
Dim ucsObj As AcadUCS
Set ucsObj = UcR 'ucs right hand side
'again this line, whether inside the function or out here, causes the ucs
change to fail and the drawing to revert to world ucs
ThisDrawing.ActiveViewport = ThisDrawing.ActiveViewport
Dim TransMatrix As Variant
TransMatrix = GetUCSMatrix(ucsObj)
Dim strMsg As String
strMsg = "Ucs matrix is: " & vbCr
Dim i As Integer
Dim j As Integer
'another weirdness (to me)
'this line bombs with subscript out of range (even though it's not)
'transmatrix has a lbound of 0 and ubound of 3
'when i = 0 I get a subscript out of range
'For i = LBound(TransMatrix) To UBound(TransMatrix)
For i = 0 To 3
'and likewise this line bombs like the above with subscript out of range
'even though it's not!
'For j = LBound(TransMatrix(i)) To UBound(TransMatrix(i))
'this hard code works and since I know the size of the matrix i guess that's
ok, except I thought it was bad practice to hard code arbitrary values and
it seems like I should be able to read the actual array size with lbound and
ubound?!?
For j = 0 To 3
strMsg = strMsg & TransMatrix(i, j) & ", "
Next j
strMsg = strMsg & vbCr
Next i
MsgBox strMsg, vbOKOnly, "Ace Destruction Co. Ucs Matrix Report"
End Sub
It does not seem to work as I would expect. (that's what I get for having
expectations!)
I start with blank dwg
create a box(3dsolid) at 0,0,0
W = 3, L = 2, H = 4
orbit to sw iso more or less to see the box and ucs icon
'...heres a function to change to 'right side ucs'
'...it should 'supposedly' change the current ucs (from world or ?) to right
side ucs
'... it then returns the new ucs object
Function UcR() As AcadUCS
Dim Neworigin(0 To 2) As Double
ThisDrawing.Utility.GetPoint Neworigin, "Pick a point, El Cadilator!"
'pick the lower right corner of box (world coord: 2,0,0)
Dim xAxisPoint(2) As Double
Dim YAxisPoint(2) As Double
Dim ucsObjR As AcadUCS
xAxisPoint(0) = Neworigin(0): xAxisPoint(1) = Neworigin(1) + 1:
xAxisPoint(2) = Neworigin(2)
YAxisPoint(0) = Neworigin(0): YAxisPoint(1) = Neworigin(1):
YAxisPoint(2) = Neworigin(2) + 1
Set ucsObjR = ThisDrawing.UserCoordinateSystems.Add(Neworigin,
xAxisPoint, YAxisPoint, "UCSRIGHT")
ThisDrawing.ActiveUCS = ucsObjR
'when the ucs origin did not change to the origin I sent to the add method
'i thought I could force it to move to the correct point with the next line
but it did no good....
'ucsObj.origin = Neworigin
'that line has no effect...(that I can see)
ThisDrawing.ActiveViewport.UCSIconOn = True
ThisDrawing.ActiveViewport.UCSIconAtOrigin = True
'the next line seems like a bug to me....
'ThisDrawing.ActiveViewport = ThisDrawing.ActiveViewport
' I would expect that command to move the ucs icon to the point I picked for
new origin, instead it changes the ucs to world and zooms to a previous view
'if I comment out that line, the ucs changes to right side but the ucs icon
does not move to world 2,0,0 as it should according to the function above,
but rather it stays at 0,0,0 and just rotates to the right side direction.
...what am I not understanding???
Set UcR = ucsObjR
End Function
...here's a sub to test the above
Sub UCSMatrixTest2()
' Define a new UCS and turn on the UCS icon at the origin.
Dim ucsObj As AcadUCS
Set ucsObj = UcR 'ucs right hand side
'again this line, whether inside the function or out here, causes the ucs
change to fail and the drawing to revert to world ucs
ThisDrawing.ActiveViewport = ThisDrawing.ActiveViewport
Dim TransMatrix As Variant
TransMatrix = GetUCSMatrix(ucsObj)
Dim strMsg As String
strMsg = "Ucs matrix is: " & vbCr
Dim i As Integer
Dim j As Integer
'another weirdness (to me)
'this line bombs with subscript out of range (even though it's not)
'transmatrix has a lbound of 0 and ubound of 3
'when i = 0 I get a subscript out of range
'For i = LBound(TransMatrix) To UBound(TransMatrix)
For i = 0 To 3
'and likewise this line bombs like the above with subscript out of range
'even though it's not!
'For j = LBound(TransMatrix(i)) To UBound(TransMatrix(i))
'this hard code works and since I know the size of the matrix i guess that's
ok, except I thought it was bad practice to hard code arbitrary values and
it seems like I should be able to read the actual array size with lbound and
ubound?!?
For j = 0 To 3
strMsg = strMsg & TransMatrix(i, j) & ", "
Next j
strMsg = strMsg & vbCr
Next i
MsgBox strMsg, vbOKOnly, "Ace Destruction Co. Ucs Matrix Report"
End Sub