Setting the Point Style Marker Size and Scale using AutoCAD Civil 3D .NET API

By Partha Sarkar

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 :

 

Civil3D_PointStyle_Marker_Setting

Hope this is useful to you!


Comments

2 responses to “Setting the Point Style Marker Size and Scale using AutoCAD Civil 3D .NET API”

  1. Mary Ann Avatar
    Mary Ann

    Is it possible in Civil3d to have the size of the point style base on field points. Let’s say, first point shot is at the center of the electrical pullbox, next shot is middle west side and the last point shot is at northwest corner of the pullbox. So the actual dimension of the utility will be shown.

  2. Hi Mary,
    Are you talking about using same Style object but with different scale factor ?
    Or different Style object (may be using same block as symbol marker and other similar properties) but a different scale for marker ?
    Thanks,
    Partha

Leave a Reply