.NET
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
How to use function "SetUcs"
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
97 Views, 7 Replies
06-01-2005 10:38 PM
Dim orthoView As New OrthographicView
Dim viewp As New Viewport
orthoView = OrthographicView.FrontView
viewp.SetUcs(orthoView) '''''''why not working???
viewp.UpdateDisplay()
btr.AppendEntity(viewp)
tm.AddNewlyCreatedDBObject(viewp, True)
Dim viewp As New Viewport
orthoView = OrthographicView.FrontView
viewp.SetUcs(orthoView) '''''''why not working???
viewp.UpdateDisplay()
btr.AppendEntity(viewp)
tm.AddNewlyCreatedDBObject(viewp, True)
*Albert Szilvasy
Re: How to use function "SetUcs"
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
06-02-2005 08:28 AM in reply to:
jiangfangji
Try setting the ucs after you added viewport to the drawing.
If that doesn't work please try to post some code that I can cut and paste
and compile (no dependencies on other stuff).
Albert
wrote in message news:4862874@discussion.autodesk.com...
Dim orthoView As New OrthographicView
Dim viewp As New Viewport
orthoView = OrthographicView.FrontView
viewp.SetUcs(orthoView) '''''''why not working???
viewp.UpdateDisplay()
btr.AppendEntity(viewp)
tm.AddNewlyCreatedDBObject(viewp, True)
If that doesn't work please try to post some code that I can cut and paste
and compile (no dependencies on other stuff).
Albert
Dim orthoView As New OrthographicView
Dim viewp As New Viewport
orthoView = OrthographicView.FrontView
viewp.SetUcs(orthoView) '''''''why not working???
viewp.UpdateDisplay()
btr.AppendEntity(viewp)
tm.AddNewlyCreatedDBObject(viewp, True)
Re: How to use function "SetUcs"
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
06-02-2005 05:35 PM in reply to:
jiangfangji
Hi Albert:
Following is the complete codes that you can compile.Please help me to find the reason why the function "SetUCS" don't work!
Private Sub btnDraw_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDraw.Click
Dim db As Database = Application.DocumentManager.MdiActiveDocument.Data base
Dim tm As DBTransMan = db.TransactionManager
Dim ta As Transaction = tm.StartTransaction
Try
Dim r, w, v, h As Double
Dim x0, y0, z0, x1, y1, z1 As Double
Dim tt, n As Integer
Dim cenX0, cenY0, cenZ0 As Double
Dim p0, p1 As Point3d
Dim p1Collection As New Point3dCollection
Dim sPline As Polyline3d
Const pi = 3.1415926
n = CInt(txtN.Text)
cenX0 = CDbl(txtX.Text)
cenY0 = CDbl(txtY.Text)
cenZ0 = CDbl(txtZ.Text)
tt = 0
r = CDbl(txtRadius.Text)
h = CDbl(txtDaoCheng.Text)
Dim bt As BlockTable = tm.GetObject(db.BlockTableId, OpenMode.ForRead, False)
Dim btr As BlockTableRecord = tm.GetObject(bt.Item(BlockTableRecord.ModelSpace), OpenMode.ForWrite, False)
w = 2 * pi / 180
v = h / 180
x0 = cenX0 + r * Cos(w * tt)
y0 = cenY0 + r * Sin(w * tt)
z0 = cenZ0 + v * tt
p0 = New Point3d(x0, y0, z0)
p1 = New Point3d(x0, y0, z0)
p1Collection.Add(p1)
tt = tt + 1
Do While (tt <= (n * 180))
x0 = cenX0 + r * Cos(w * tt)
y0 = cenY0 + r * Sin(w * tt)
z0 = cenZ0 + v * tt
p1 = New Point3d(x0, y0, z0)
p1 = New Point3d(x0, y0, z0)
p1Collection.Add(p1)
tt = tt + 1
Loop
sPline = New Polyline3d(Poly3dType.SimplePoly, p1Collection, False)
btr.AppendEntity(sPline)
tm.AddNewlyCreatedDBObject(sPline, True)
'''''''''Draw Screw Solid '''''''''''''''''''''''''''''''''
Dim dboCol As New DBObjectCollection
Dim cir As New Circle
Dim solid3dScrew As New Solid3d
Dim regionCir As Region
Dim regions As DBObjectCollection
''''''''''''''''''''''''''''''UCS should be changed to FrontView from TopView,But the SetUCS can not goog work!!!!!!!!!!
Dim orthoView As New OrthographicView
Dim viewp As New Viewport
orthoView = OrthographicView.FrontView
viewp.SetUcs(orthoView)
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''
cir.Center = p0
cir.Radius = 10
dboCol.Clear()
dboCol.Add(cir)
btr.AppendEntity(cir)
tm.AddNewlyCreatedDBObject(cir, True)
regions = regionCir.CreateFromCurves(dboCol)
regionCir = regions(0)
'solid3dScrew.ExtrudeAlongPath(regionCir, sPline, 0)
btr.AppendEntity(solid3dScrew)
tm.AddNewlyCreatedDBObject(solid3dScrew, True)
regions.Dispose()
'''''''''Draw Screw Solid '''''''''''''''''''''''''''''''''
ta.Commit()
Catch
MsgBox( Err.Description, MsgBoxStyle.Critical, "Error")
Finally
ta.Dispose()
End Try
End Sub
Following is the complete codes that you can compile.Please help me to find the reason why the function "SetUCS" don't work!
Private Sub btnDraw_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDraw.Click
Dim db As Database = Application.DocumentManager.MdiActiveDocument.Data
Dim tm As DBTransMan = db.TransactionManager
Dim ta As Transaction = tm.StartTransaction
Try
Dim r, w, v, h As Double
Dim x0, y0, z0, x1, y1, z1 As Double
Dim tt, n As Integer
Dim cenX0, cenY0, cenZ0 As Double
Dim p0, p1 As Point3d
Dim p1Collection As New Point3dCollection
Dim sPline As Polyline3d
Const pi = 3.1415926
n = CInt(txtN.Text)
cenX0 = CDbl(txtX.Text)
cenY0 = CDbl(txtY.Text)
cenZ0 = CDbl(txtZ.Text)
tt = 0
r = CDbl(txtRadius.Text)
h = CDbl(txtDaoCheng.Text)
Dim bt As BlockTable = tm.GetObject(db.BlockTableId, OpenMode.ForRead, False)
Dim btr As BlockTableRecord = tm.GetObject(bt.Item(BlockTableRecord.ModelSpace), OpenMode.ForWrite, False)
w = 2 * pi / 180
v = h / 180
x0 = cenX0 + r * Cos(w * tt)
y0 = cenY0 + r * Sin(w * tt)
z0 = cenZ0 + v * tt
p0 = New Point3d(x0, y0, z0)
p1 = New Point3d(x0, y0, z0)
p1Collection.Add(p1)
tt = tt + 1
Do While (tt <= (n * 180))
x0 = cenX0 + r * Cos(w * tt)
y0 = cenY0 + r * Sin(w * tt)
z0 = cenZ0 + v * tt
p1 = New Point3d(x0, y0, z0)
p1 = New Point3d(x0, y0, z0)
p1Collection.Add(p1)
tt = tt + 1
Loop
sPline = New Polyline3d(Poly3dType.SimplePoly, p1Collection, False)
btr.AppendEntity(sPline)
tm.AddNewlyCreatedDBObject(sPline, True)
'''''''''Draw Screw Solid '''''''''''''''''''''''''''''''''
Dim dboCol As New DBObjectCollection
Dim cir As New Circle
Dim solid3dScrew As New Solid3d
Dim regionCir As Region
Dim regions As DBObjectCollection
''''''''''''''''''''''''''''''UCS should be changed to FrontView from TopView,But the SetUCS can not goog work!!!!!!!!!!
Dim orthoView As New OrthographicView
Dim viewp As New Viewport
orthoView = OrthographicView.FrontView
viewp.SetUcs(orthoView)
''''''''''''''''''''''''''''''''''''''''''''''''''
cir.Center = p0
cir.Radius = 10
dboCol.Clear()
dboCol.Add(cir)
btr.AppendEntity(cir)
tm.AddNewlyCreatedDBObject(cir, True)
regions = regionCir.CreateFromCurves(dboCol)
regionCir = regions(0)
'solid3dScrew.ExtrudeAlongPath(regionCir, sPline, 0)
btr.AppendEntity(solid3dScrew)
tm.AddNewlyCreatedDBObject(solid3dScrew, True)
regions.Dispose()
'''''''''Draw Screw Solid '''''''''''''''''''''''''''''''''
ta.Commit()
Catch
MsgBox( Err.Description, MsgBoxStyle.Critical, "Error")
Finally
ta.Dispose()
End Try
End Sub
*Albert Szilvasy
Re: How to use function "SetUcs"
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
06-02-2005 05:59 PM in reply to:
jiangfangji
Ok. What are you trying to do? Let me rephrase in english what you are
doing:
1. You create a new viewport
2. You set the UCS in the viewport.
Note that you never add the viewport to the drawing and you never set any of
the view properties so it is unclear what this viewport is supposed to view.
I suspect that you want to set the ucs in the current viewport. Is that it?
Albert
wrote in message news:4864232@discussion.autodesk.com...
Hi Albert:
Following is the complete codes that you can compile.Please help me to find
the reason why the function "SetUCS" don't work!
Private Sub btnDraw_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnDraw.Click
Dim db As Database =
Application.DocumentManager.MdiActiveDocument.Data base
Dim tm As DBTransMan = db.TransactionManager
Dim ta As Transaction = tm.StartTransaction
Try
Dim r, w, v, h As Double
Dim x0, y0, z0, x1, y1, z1 As Double
Dim tt, n As Integer
Dim cenX0, cenY0, cenZ0 As Double
Dim p0, p1 As Point3d
Dim p1Collection As New Point3dCollection
Dim sPline As Polyline3d
Const pi = 3.1415926
n = CInt(txtN.Text)
cenX0 = CDbl(txtX.Text)
cenY0 = CDbl(txtY.Text)
cenZ0 = CDbl(txtZ.Text)
tt = 0
r = CDbl(txtRadius.Text)
h = CDbl(txtDaoCheng.Text)
Dim bt As BlockTable = tm.GetObject(db.BlockTableId,
OpenMode.ForRead, False)
Dim btr As BlockTableRecord =
tm.GetObject(bt.Item(BlockTableRecord.ModelSpace), OpenMode.ForWrite, False)
w = 2 * pi / 180
v = h / 180
x0 = cenX0 + r * Cos(w * tt)
y0 = cenY0 + r * Sin(w * tt)
z0 = cenZ0 + v * tt
p0 = New Point3d(x0, y0, z0)
p1 = New Point3d(x0, y0, z0)
p1Collection.Add(p1)
tt = tt + 1
Do While (tt <= (n * 180))
x0 = cenX0 + r * Cos(w * tt)
y0 = cenY0 + r * Sin(w * tt)
z0 = cenZ0 + v * tt
p1 = New Point3d(x0, y0, z0)
p1 = New Point3d(x0, y0, z0)
p1Collection.Add(p1)
tt = tt + 1
Loop
sPline = New Polyline3d(Poly3dType.SimplePoly, p1Collection,
False)
btr.AppendEntity(sPline)
tm.AddNewlyCreatedDBObject(sPline, True)
'''''''''Draw Screw Solid '''''''''''''''''''''''''''''''''
Dim dboCol As New DBObjectCollection
Dim cir As New Circle
Dim solid3dScrew As New Solid3d
Dim regionCir As Region
Dim regions As DBObjectCollection
''''''''''''''''''''''''''''''UCS should be changed to FrontView from
TopView,But the SetUCS can not goog work!!!!!!!!!!
Dim orthoView As New OrthographicView
Dim viewp As New Viewport
orthoView = OrthographicView.FrontView
viewp.SetUcs(orthoView)
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''
cir.Center = p0
cir.Radius = 10
dboCol.Clear()
dboCol.Add(cir)
btr.AppendEntity(cir)
tm.AddNewlyCreatedDBObject(cir, True)
regions = regionCir.CreateFromCurves(dboCol)
regionCir = regions(0)
'solid3dScrew.ExtrudeAlongPath(regionCir, sPline, 0)
btr.AppendEntity(solid3dScrew)
tm.AddNewlyCreatedDBObject(solid3dScrew, True)
regions.Dispose()
'''''''''Draw Screw Solid '''''''''''''''''''''''''''''''''
ta.Commit()
Catch
MsgBox( Err.Description, MsgBoxStyle.Critical, "Error")
Finally
ta.Dispose()
End Try
End Sub
doing:
1. You create a new viewport
2. You set the UCS in the viewport.
Note that you never add the viewport to the drawing and you never set any of
the view properties so it is unclear what this viewport is supposed to view.
I suspect that you want to set the ucs in the current viewport. Is that it?
Albert
Hi Albert:
Following is the complete codes that you can compile.Please help me to find
the reason why the function "SetUCS" don't work!
Private Sub btnDraw_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnDraw.Click
Dim db As Database =
Application.DocumentManager.MdiActiveDocument.Data
Dim tm As DBTransMan = db.TransactionManager
Dim ta As Transaction = tm.StartTransaction
Try
Dim r, w, v, h As Double
Dim x0, y0, z0, x1, y1, z1 As Double
Dim tt, n As Integer
Dim cenX0, cenY0, cenZ0 As Double
Dim p0, p1 As Point3d
Dim p1Collection As New Point3dCollection
Dim sPline As Polyline3d
Const pi = 3.1415926
n = CInt(txtN.Text)
cenX0 = CDbl(txtX.Text)
cenY0 = CDbl(txtY.Text)
cenZ0 = CDbl(txtZ.Text)
tt = 0
r = CDbl(txtRadius.Text)
h = CDbl(txtDaoCheng.Text)
Dim bt As BlockTable = tm.GetObject(db.BlockTableId,
OpenMode.ForRead, False)
Dim btr As BlockTableRecord =
tm.GetObject(bt.Item(BlockTableRecord.ModelSpace), OpenMode.ForWrite, False)
w = 2 * pi / 180
v = h / 180
x0 = cenX0 + r * Cos(w * tt)
y0 = cenY0 + r * Sin(w * tt)
z0 = cenZ0 + v * tt
p0 = New Point3d(x0, y0, z0)
p1 = New Point3d(x0, y0, z0)
p1Collection.Add(p1)
tt = tt + 1
Do While (tt <= (n * 180))
x0 = cenX0 + r * Cos(w * tt)
y0 = cenY0 + r * Sin(w * tt)
z0 = cenZ0 + v * tt
p1 = New Point3d(x0, y0, z0)
p1 = New Point3d(x0, y0, z0)
p1Collection.Add(p1)
tt = tt + 1
Loop
sPline = New Polyline3d(Poly3dType.SimplePoly, p1Collection,
False)
btr.AppendEntity(sPline)
tm.AddNewlyCreatedDBObject(sPline, True)
'''''''''Draw Screw Solid '''''''''''''''''''''''''''''''''
Dim dboCol As New DBObjectCollection
Dim cir As New Circle
Dim solid3dScrew As New Solid3d
Dim regionCir As Region
Dim regions As DBObjectCollection
''''''''''''''''''''''''''''''UCS should be changed to FrontView from
TopView,But the SetUCS can not goog work!!!!!!!!!!
Dim orthoView As New OrthographicView
Dim viewp As New Viewport
orthoView = OrthographicView.FrontView
viewp.SetUcs(orthoView)
''''''''''''''''''''''''''''''''''''''''''''''''''
cir.Center = p0
cir.Radius = 10
dboCol.Clear()
dboCol.Add(cir)
btr.AppendEntity(cir)
tm.AddNewlyCreatedDBObject(cir, True)
regions = regionCir.CreateFromCurves(dboCol)
regionCir = regions(0)
'solid3dScrew.ExtrudeAlongPath(regionCir, sPline, 0)
btr.AppendEntity(solid3dScrew)
tm.AddNewlyCreatedDBObject(solid3dScrew, True)
regions.Dispose()
'''''''''Draw Screw Solid '''''''''''''''''''''''''''''''''
ta.Commit()
Catch
MsgBox( Err.Description, MsgBoxStyle.Critical, "Error")
Finally
ta.Dispose()
End Try
End Sub
Re: How to use function "SetUcs"
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
06-02-2005 10:30 PM in reply to:
jiangfangji
Hi Albert:
I want to set the ucs in the current viewport from TopView to FrontView becase I want to draw a circle in the FronView not TopView. And then I will extrude the circle entity along a 3DPolyLine path . But How to do it?
I want to set the ucs in the current viewport from TopView to FrontView becase I want to draw a circle in the FronView not TopView. And then I will extrude the circle entity along a 3DPolyLine path . But How to do it?
*Albert Szilvasy
Re: How to use function "SetUcs"
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
06-03-2005 08:21 AM in reply to:
jiangfangji
You don't need to set the ucs to do this. You simply set the normal of the
Circle to say -1,0,0.
ALbert
wrote in message news:4864333@discussion.autodesk.com...
Hi Albert:
I want to set the ucs in the current viewport from TopView to FrontView
becase I want to draw a circle in the FronView not TopView. And then I will
extrude the circle entity along a 3DPolyLine path . But How to do it?
Circle to say -1,0,0.
ALbert
Hi Albert:
I want to set the ucs in the current viewport from TopView to FrontView
becase I want to draw a circle in the FronView not TopView. And then I will
extrude the circle entity along a 3DPolyLine path . But How to do it?
Re: How to use function "SetUcs"
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
06-06-2005 01:39 AM in reply to:
jiangfangji
Hi Albert:
Can you give me some sample codes about how to do it?
Regards.
John Jiang
Can you give me some sample codes about how to do it?
Regards.
John Jiang
*Albert Szilvasy
Re: How to use function "SetUcs"
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
06-06-2005 09:17 AM in reply to:
jiangfangji
Here you go:
public class CircleCreator
{
[CommandMethod("cc")]
public void DoIt()
{
Database db =
Application.DocumentManager.MdiActiveDocument.Data base;
using (Transaction t = db.TransactionManager.StartTransaction())
{
BlockTable bt = (BlockTable)t.GetObject(db.BlockTableId,
OpenMode.ForRead);
BlockTableRecord btr =
(BlockTableRecord)t.GetObject(bt[BlockTableRecord. ModelSpace],
OpenMode.ForWrite);
//create circle with some arbitrary normal
using (Circle c = new Circle(new Point3d(0,0, 0),new
Vector3d(1,1,1),1))
{
btr.AppendEntity(c);
t.AddNewlyCreatedDBObject(c, true);
}
t.Commit();
}
}
}
wrote in message news:4866005@discussion.autodesk.com...
Hi Albert:
Can you give me some sample codes about how to do it?
Regards.
John Jiang
public class CircleCreator
{
[CommandMethod("cc")]
public void DoIt()
{
Database db =
Application.DocumentManager.MdiActiveDocument.Data
using (Transaction t = db.TransactionManager.StartTransaction())
{
BlockTable bt = (BlockTable)t.GetObject(db.BlockTableId,
OpenMode.ForRead);
BlockTableRecord btr =
(BlockTableRecord)t.GetObject(bt[BlockTableRecord.
OpenMode.ForWrite);
//create circle with some arbitrary normal
using (Circle c = new Circle(new Point3d(0,0, 0),new
Vector3d(1,1,1),1))
{
btr.AppendEntity(c);
t.AddNewlyCreatedDBObject(c, true);
}
t.Commit();
}
}
}
Hi Albert:
Can you give me some sample codes about how to do it?
Regards.
John Jiang
