I'm fairly new to this, but I'm confused looking through the vb.net developer's guide and online for information about transforming the UCS.
I'd like to:
1: Save the user's current UCS,
2: Change to the World UCS (that's easy)
2: Do things
3: Set the UCS back to the user's original UCS
Is there no simple way to do this?
If not I may have to learn more about matrix operations than I really wanted to
Thanks,
David
Part of what I'm doing involves extrusions, and I get unpredictable results if I don't first set the UCS to world.
In VBA this was fairly straightforward, but different in vb.net, hence the posting.
You can P/Invoke acedSetCurrentUCS, acedGetCurrentUCS and acedRestorePreviousUCS
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"
Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
After doing some research, part of my problem was not knowing what I was looking for. The following code does what I need, except for one thing:
The viewport changes to the orthogonal plan view at the end of the toUser Sub.
How do I keep the user's viewport view as-is?
Thanks,
David
Public vect1 As Vector3d
Public vect2 As Vector3d
Public org As Point3d
Public Sub toWorld()
Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim acCurDb As Database = acDoc.Database
vect1 = acCurDb.Ucsxdir
vect2 = acCurDb.Ucsydir
org = acCurDb.Ucsorg
acDoc.Editor.CurrentUserCoordinateSystem = Matrix3d.Identity
End Sub
Public Sub restoreUCS()
Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim acCurDb As Database = acDoc.Database
Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
'' Open the UCS table for read
Dim acUCSTbl As UcsTable
acUCSTbl = acTrans.GetObject(acCurDb.UcsTableId, OpenMode.ForRead)
Dim acUCSTblRec As UcsTableRecord
If acUCSTbl.Has("New_UCS") = False Then
acUCSTblRec = New UcsTableRecord()
acUCSTblRec.Name = "New_UCS"
acUCSTbl.UpgradeOpen()
acUCSTbl.Add(acUCSTblRec)
acTrans.AddNewlyCreatedDBObject(acUCSTblRec, True)
Else
acUCSTblRec = acTrans.GetObject(acUCSTbl("New_UCS"), OpenMode.ForWrite)
End If
acUCSTblRec.Origin = org
acUCSTblRec.XAxis = vect1
acUCSTblRec.YAxis = vect2
'' Open the active viewport
Dim acVportTblRec As ViewportTableRecord
'' Set the UCS current
acVportTblRec.SetUcs(acUCSTblRec.ObjectId)
acDoc.Editor.UpdateTiledViewportsFromDatabase()
acTrans.Commit()
End Using
End Sub
Hi David, I am trying to do the same thing you are trying to do. I would like to change the UCS then create a polyline on a new UCS (not same as WCS). But when I create a polyline it adds it using WCS. Can you please point me to the right direction.
Thank you,
See this article about using Editor.CurrentUserCoordinateSystem Property