- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm attempting to create a helix programmatically, but it doesn't work. Half the time it crashes autocad, and half the time it draws a helix that doesn't follow the parameters I set. Can someone tell me what I'm doing wrong? Here is the code:
public static ObjectId DrawHelix(Transaction transaction, Point3d startPoint, Vector3d axis, double radius, double height, double numberOfTurns, bool isLeft)
{
try
{
// Open the Block table for read
using (BlockTable _blockTable = transaction.GetObject(Utils.ActiveDatabase.BlockTableId, OpenMode.ForRead) as BlockTable)
{
// Open the Block table record Model space for write
using (BlockTableRecord _blockTableRecord = transaction.GetObject(_blockTable[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord)
{
using (Helix _helix = new Helix())
{
_helix.BaseRadius = radius;
_helix.TopRadius = radius;
_helix.StartPoint = startPoint;
//_helix.EndPoint = endPoint; not implemented exception?
_helix.Height = height;
_helix.Turns = numberOfTurns;
_helix.Twist = isLeft;
//_helix.AxisVector = axis;
_blockTableRecord.AppendEntity(_helix);
transaction.AddNewlyCreatedDBObject(_helix, true);
return _helix.Id;
}
}
}
}
catch
{
throw new System.Exception();
}
}
Specific questions:
1) Do I have to set the properties of the helix in a particular order?
2) Does the StartPoint property actually control the start of the helix? On the occasions when this function works, the resulting helix is never drawn anywhere near the given start point.
3) Autocad's HELIX command asks the user to select a center point, but the Helix class doesn't have a CenterPoint property. Is there a way to set the center point programmatically?
4) What is the AxisVector supposed to control? I commented it out because it never seemed to affect anything.
5) If I later want to sweep a rectangle along the helix object, can I use the helix directly, or do I need to cast it to another type?
Solved! Go to Solution.