Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Every time while initializing this class its stopping and crashing Revit or without debugger stepping forward staying in working mode forever.
I'm quite new in event creation, is there something wrong I'm doing here?
class DummyTag
{
public STag tag { get; set; }
private event EventHandler ElbowModified;
private event EventHandler BoundingBoxModified;
public XYZ Start { get; set; }
public XYZ Elbow { get { return Elbow; } set { Elbow = value; ElbowModified.Invoke(this, EventArgs.Empty); } }
public XYZ End { get; set; }
public BoundingBoxXYZ boundingBox { get { return boundingBox; } set { boundingBox = value; BoundingBoxModified.Invoke(this, EventArgs.Empty); } }
public DummyTag()
{
ElbowModified += DummyTag_ElbowModified;
BoundingBoxModified += DummyTag_BoundingBoxModified;
}
public DummyTag(STag sTag)
{
ElbowModified += DummyTag_ElbowModified;
BoundingBoxModified += DummyTag_BoundingBoxModified;
tag = sTag;
this.Start = sTag.PrimaryLine.GetEndPoint(0);
if (sTag.SecondaryLine is null)
{
this.End = sTag.PrimaryLine.GetEndPoint(1);
}
else
{
this.End = sTag.SecondaryLine.GetEndPoint(1);
}
if (sTag.TagObject.HasElbow)
{
this.Elbow = sTag.TagObject.LeaderElbow;
}
else
{
this.Elbow = (this.Start + this.End).Multiply(.5);
}
}
private void DummyTag_ElbowModified(object sender, EventArgs e)
{
if (Elbow != null && boundingBox != null)
{
Start = STag.ClosestPoint(Elbow, boundingBox);
}
}
private void DummyTag_BoundingBoxModified(object sender, EventArgs e)
{
if (Elbow != null && boundingBox != null)
{
Start = STag.ClosestPoint(Elbow, boundingBox);
}
}
public STag STagObject()
{
tag.BoundingBox = this.boundingBox;
tag.PrimaryLine = Line.CreateBound(Start, Elbow);
tag.SecondaryLine = Line.CreateBound(Elbow, End);
return tag;
}
}
Solved! Go to Solution.