Editing Existing Dimensions

Editing Existing Dimensions

strsuraj
Enthusiast Enthusiast
939 Views
1 Reply
Message 1 of 2

Editing Existing Dimensions

strsuraj
Enthusiast
Enthusiast

Hello everyone,

I am using Revit 2015 and VS 2013.

I want to change few properties of the existing dimension like "Witness Line Control" from -> Fixed to Dimension Line to "Gap to Element". 

 

This is what I have done so far, but didn't really gave me the results intended. I am able to change the position of Dimension but not edit this property.

using(Transaction trans = new Transaction(doc, "ModifyDim"))
{
   trans.Start();
   foreach (Dimension dim in coll)
   {
      int count = dim.Segments.Size;
      if(count > 0)
      {
         for (int i = 0; i < count; i++)
         {
             if (dim.Segments.get_Item(i).ValueString == "5880")
             {
// trying to change the witness line control property ElementType dimType = doc.GetElement(dim.GetTypeId()) as ElementType; Parameter attribute = dimType.get_Parameter(BuiltInParameter.DIM_WITNS_LINE_CNTRL); bool value = attribute.HasValue; attribute.SetValueString("Gap to Element"); attribute.Set("Gap to Element");

// Moving dim to new position XYZ point = new XYZ(0, 50, 0); dim.Location.Move(point); } } } else { if(dim.ValueString == "1740") { XYZ point = new XYZ(80, 0, 0); dim.Location.Move(point); } } } trans.Commit(); }

Looking forward to any help or tips on how can I achieve this.

 

 

image3.png

Thanks 

Suraj

0 Likes
Accepted solutions (1)
940 Views
1 Reply
Reply (1)
Message 2 of 2

strsuraj
Enthusiast
Enthusiast
Accepted solution

Ohh my bad, I was messing it up.

 

BuiltInParameter.DIM_WITNS_LINE_CNTRL 

 This has storage type - Integer and I was passing string value.

 

Solution is :

// Change the witness line control property
ElementType dimType = doc.GetElement(dim.GetTypeId()) as ElementType;
Parameter attribute = dimType.get_Parameter(BuiltInParameter.DIM_WITNS_LINE_CNTRL);
attribute.Set(0); // 0 being the index for "Gap to Element"

Thanks.

 

Suraj

 

0 Likes