If you want to create a new PointStyle object in AutoCAD
Civil 3D and set the Marker Size and Scale using .NET API, you first need to
create the new Point style or access the point style object you want to modify
and then set the SizeType property to use the MarkerSizeType enum values that
defines how the marker is sized such as ‘Use drawing scale’ or ‘Use fixed scale’
etc. Next set the MarkerSize or Scale values accordingly.
Here
is a C# .NET code snippet demonstrating the same :
using (Transaction trans = db.TransactionManager.StartTransaction())
{
// Create a point style that uses a custom marker
// and set the Size and scale
ObjectId pointStyleId = civilDoc.Styles.PointStyles.Add("My DEMO Point Style");
PointStyle pointStyle = pointStyleId.GetObject(OpenMode.ForWrite) as PointStyle;
pointStyle.MarkerType = PointMarkerDisplayType.UseCustomMarker;
pointStyle.CustomMarkerStyle = CustomMarkerType.CustomMarkerX;
pointStyle.CustomMarkerSuperimposeStyle = CustomMarkerSuperimposeType.Circle;
// set the size to use 'Drawing Scale'
pointStyle.SizeType = MarkerSizeType.DrawingScale;
pointStyle.MarkerSize = 0.003;
// If you want to set the size to use 'Fixed Scale'
//pointStyle.SizeType = MarkerSizeType.FixedScale;
//Point3d markerfixedscalePoint3d = new Point3d(3, 3, 3);
//pointStyle.MarkerFixedScale = markerfixedscalePoint3d;
trans.Commit();
}
Here is a screenshot of my new PointStyle with custom Marker :
Hope this is useful to you!


Leave a Reply