.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to use function "SetUcs"

7 REPLIES 7
Reply
Message 1 of 8
Anonymous
837 Views, 7 Replies

How to use function "SetUcs"

Anonymous
Not applicable
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)
0 Likes

How to use function "SetUcs"

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)
7 REPLIES 7
Message 2 of 8
Anonymous
in reply to: Anonymous

Anonymous
Not applicable
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)
0 Likes

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)
Message 3 of 8
Anonymous
in reply to: Anonymous

Anonymous
Not applicable
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.Database
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
0 Likes

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.Database
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
Message 4 of 8
Anonymous
in reply to: Anonymous

Anonymous
Not applicable
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.Database
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
0 Likes

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.Database
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
Message 5 of 8
Anonymous
in reply to: Anonymous

Anonymous
Not applicable
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?
0 Likes

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?
Message 6 of 8
Anonymous
in reply to: Anonymous

Anonymous
Not applicable
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?
0 Likes

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?
Message 7 of 8
Anonymous
in reply to: Anonymous

Anonymous
Not applicable
Hi Albert:
Can you give me some sample codes about how to do it?
Regards.
John Jiang
0 Likes

Hi Albert:
Can you give me some sample codes about how to do it?
Regards.
John Jiang
Message 8 of 8
Anonymous
in reply to: Anonymous

Anonymous
Not applicable
Here you go:

public class CircleCreator
{
[CommandMethod("cc")]
public void DoIt()
{
Database db =
Application.DocumentManager.MdiActiveDocument.Database;
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
0 Likes

Here you go:

public class CircleCreator
{
[CommandMethod("cc")]
public void DoIt()
{
Database db =
Application.DocumentManager.MdiActiveDocument.Database;
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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report