GetOffsetCurves(distance) in .NET produces similar results. I need to test if it’s an AcDbPolyline, if so change the sign of distance.
Here is the code if anyone wants to test.
namespace ExecMethod
{
public class Commands
{
[CommandMethod("doit")]
static public void doit()
{
Editor ed = AcAp.Application.DocumentManager.MdiActiveDocument.Editor;
Database db = HostApplicationServices.WorkingDatabase;
try
{
PromptEntityOptions peo = new PromptEntityOptions("\nGet Entity: ");
peo.AllowNone = false;
PromptEntityResult per = ed.GetEntity(peo);
if (per.Status == PromptStatus.OK)
{
PromptDistanceOptions pdo = new PromptDistanceOptions("\nGet Distance: ");
PromptDoubleResult pdr = ed.GetDistance(pdo);
if (pdr.Status == PromptStatus.OK)
{
Offset(db, per.ObjectId, pdr.Value);
}
}
}
catch (System.Exception ex)
{
ed.WriteMessage(ex.Message);
ed.WriteMessage(ex.StackTrace);
}
}
public static void Offset(Database db, ObjectId id, double distance)
{
AcDb.TransactionManager manager = db.TransactionManager;
using (Transaction transaction = manager.StartTransaction())
{
BlockTableRecord record = (BlockTableRecord)transaction.GetObject
(SymbolUtilityServices.GetBlockModelSpaceId(db), OpenMode.ForWrite, false);
Curve curve = transaction.GetObject(id, OpenMode.ForRead, false) as Curve;
if (curve.GetRXClass().Name == "AcDbPolyline") //[color=red]<--------------------------- Test[/color]
{
distance = -distance;
}
DBObjectCollection offsetCurves = curve.GetOffsetCurves(distance);
foreach (Entity obj in offsetCurves)
{
record.AppendEntity(obj);
transaction.AddNewlyCreatedDBObject(obj, true);
}
transaction.Commit();
}
}
}
}