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

How can I create a solid3d Entity with a lwpolyline curve?

4 REPLIES 4
Reply
Message 1 of 5
icom99
326 Views, 4 Replies

How can I create a solid3d Entity with a lwpolyline curve?

I have some 2D polyline curve, and the curve has bulges, now I can create a solid3D Entities with this polyline and _extrude command by the direction point(0, 0, 0) to point(30, 40, 50). But now I want to create the same solid3D in .NET, how can I do that? I’m using the vs2005(C#) and autocad2008. Thanks a lots.
4 REPLIES 4
Message 2 of 5
icom99
in reply to: icom99

I have read the sample:ObjectARX_2008_32Bit\samples\dotNet\Managed_SurfaceHelix, and i know how to create a surface with a polyline, but i don't know how to create a solid3d still, please help me.
Message 3 of 5
cadMeUp
in reply to: icom99

You can start with this and alter it as needed:

Editor editor = AcadApp.DocumentManager.MdiActiveDocument.Editor;
Database db = AcadApp.DocumentManager.MdiActiveDocument.Database;
TransMan transMgr = db.TransactionManager;

using (Transaction trans = transMgr.StartTransaction())
{
BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForWrite);
BlockTableRecord ms = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite, false);

//==================================================
// Create the polyline curve
Point3dCollection pnts = new Point3dCollection();
pnts.Add(new Point3d(0, 0, 0));
pnts.Add(new Point3d(1, 0, 0));
pnts.Add(new Point3d(2, 3, 0));
pnts.Add(new Point3d(0, 2, 0));

DoubleCollection bulges = new DoubleCollection();
bulges.Add(0.5);
bulges.Add(0.75);
bulges.Add(0.3);
bulges.Add(0.9);

Polyline2d poly2d = new Polyline2d(Poly2dType.QuadSplinePoly,
pnts, 0.0, true, 0.0, 0.0, bulges);

//==================================================
// Add the curve to a DBObjectCollection.
DBObjectCollection curveCol = new DBObjectCollection();
curveCol.Add(poly2d);

//==================================================
// Create a region collection from the curve. In this example the collection
// should only contain 1 new region
DBObjectCollection regionCol = Region.CreateFromCurves(curveCol);
Region region = (Region)regionCol[0];

//==================================================
// Create the 'extude along path' line.
Line pathLine = new Line(new Point3d(0, 0, 0), new Point3d(30, 40, 50));

//==================================================
// Create the solid.
Solid3d solid = new Solid3d();
solid.ExtrudeAlongPath(region, pathLine, 0.0);

ms.AppendEntity(solid);
trans.AddNewlyCreatedDBObject(solid, true);

poly2d.Dispose();
pathLine.Dispose();
region.Dispose();

trans.Commit();
}
Message 4 of 5
zseraph
in reply to: icom99

when i Create the Solid3d

how to add Material to it ??
Message 5 of 5
cadMeUp
in reply to: icom99

Database db = AcadApp.DocumentManager.MdiActiveDocument.Database;
TransMan transMgr = db.TransactionManager;

using (Transaction trans = transMgr.StartTransaction())
{
string materialName = "MATERIAL_NAME";

ObjectId matId = ObjectId.Null;

DBDictionary materialDict = (DBDictionary)trans.GetObject(db.MaterialDictionaryId, OpenMode.ForWrite);

if(materialDict.Contains(materialName))
{
try
{
matId = (ObjectId)materialDict[materialName];
}
catch
{
// Error: could not get materialName id.
// Return here ?
}
}
else
{
// Material name not found in the materialDict
// Need to add or cancel the function ?
}


// Your solid entity
Solid3d someSolidEnt;

// Set the id of the retrieved material
if(matId != ObjectId.Null)
someSolidEnt.MaterialId = matId

trans.Commit();
}

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost