.NET

Reply
Member
zmkm1234
Posts: 4
Registered: ‎10-24-2006
Message 1 of 3 (107 Views)

create solid3d error?

107 Views, 2 Replies
11-29-2006 12:53 AM
this is my code:
db.Solid3d sol =null;
for(int i=0;i<10;i++)
for(int j=0;j<20;j++)
{
try
{
db.Solid3d sol1 = this.CreateSolid3D1(i,j,btmElevation);
db.Solid3d sol2 = this.CreateSolid3D2(i,j,btmElevation);
sol1.BooleanOperation(db.BooleanOperationType.BoolUnite,sol2);
if (i>0 || j>0)
{
sol.BooleanOperation(db.BooleanOperationType.BoolUnite,sol1);
}
else
{
sol = sol1;
}
}
catch(System.Exception ex)
{
Editor ed = acad.Application.DocumentManager.MdiActiveDocument.Editor;
ed.WriteMessage(ex.Message);
}
}

return sol;



private db.Solid3d CreateSolid3D1(int rowNum, int colNum, double btmElevation)
{
gm.Point3d pt1 = new Point3d(xPos + cell * colNum,
yPos - cell * rowNum, btmElevation);
gm.Point3d pt2 = new Point3d(xPos + cell * (1+colNum),
yPos - cell * rowNum, btmElevation);
gm.Point3d pt3 = new Point3d(xPos + cell * colNum,
yPos - cell * (rowNum+1), btmElevation);
db.Line l1 = new db.Line(pt1,pt2);
db.Line l2 = new db.Line(pt2,pt3);
db.Line l3 = new db.Line(pt3,pt1);
db.DBObjectCollection collection = new DBObjectCollection();
collection.Add(l1);
collection.Add(l2);
collection.Add(l3);
db.Region r = (db.Region)(db.Region.CreateFromCurves(collection)[0]);

db.Solid3d sol = new Solid3d();
double hgt = Math.Max(hgts[rowNum,colNum],hgts[rowNum,colNum + 1]);
hgt = Math.Max(hgt,hgts[rowNum+1,colNum]);
hgt -= btmElevation;
sol.Extrude(r,hgt,0);

pt1 = pt1.Add( new gm.Vector3d(0,0,hgts[rowNum,colNum]));
pt2 = pt2.Add( new gm.Vector3d(0,0,hgts[rowNum,colNum+1]));
pt3 = pt3.Add( new gm.Vector3d(0,0,hgts[rowNum+1,colNum]));

gm.Plane pl = new Plane(pt1,pt2,pt3);

return sol.GetSlice(pl,true);
}



private db.Solid3d CreateSolid3D2(int rowNum, int colNum, double btmElevation)
{
gm.Point3d pt2 = new Point3d(xPos + cell * (1+colNum),
yPos - cell * rowNum, btmElevation);
gm.Point3d pt3 = new Point3d(xPos + cell * colNum,
yPos - cell * (rowNum+1), btmElevation);
gm.Point3d pt4 = new Point3d(xPos + cell * (1+colNum),
yPos - cell * (1+rowNum), btmElevation);
db.Line l1 = new db.Line(pt2,pt3);
db.Line l2 = new db.Line(pt3,pt4);
db.Line l3 = new db.Line(pt4,pt2);
db.DBObjectCollection collection = new DBObjectCollection();
collection.Add(l1);
collection.Add(l2);
collection.Add(l3);
db.Region r = (db.Region)(db.Region.CreateFromCurves(collection)[0]);

db.Solid3d sol = new Solid3d();
double hgt = Math.Max(hgts[rowNum+1,colNum+1],hgts[rowNum,colNum + 1]);
hgt = Math.Max(hgt,hgts[rowNum+1,colNum]);
hgt -= btmElevation;
sol.Extrude(r,hgt,0);

pt2 = pt2.Add(new gm.Vector3d(0,0,hgts[rowNum,colNum+1]));
pt3 = pt3.Add(new gm.Vector3d(0,0,hgts[rowNum+1,colNum]));
pt4 = pt4.Add(new gm.Vector3d(0,0,hgts[rowNum+1,colNum+1]));

gm.Plane pl = new Plane(pt2,pt4,pt3);


return sol.GetSlice(pl,true);
}

when execute more number ,error ocurred.
对象的当前状态使该操作无效。

How can i do?
Member
zmkm1234
Posts: 4
Registered: ‎10-24-2006
Message 2 of 3 (107 Views)

Re: create solid3d error?

11-29-2006 01:29 AM in reply to: zmkm1234
i can not speak english.
who help me,thanks very much.
Member
zmkm1234
Posts: 4
Registered: ‎10-24-2006
Message 3 of 3 (107 Views)

Re: create solid3d error?

11-30-2006 05:32 PM in reply to: zmkm1234
ok,reason is getslice() function,plane param must intersect with solid
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.