Revit is crashing initializing this class

Revit is crashing initializing this class

sahin.ikbal
Advocate Advocate
351 Views
2 Replies
Message 1 of 3

Revit is crashing initializing this class

sahin.ikbal
Advocate
Advocate

 

 

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;
        }
    }

 

 

 

 

 

0 Likes
Accepted solutions (1)
352 Views
2 Replies
Replies (2)
Message 2 of 3

sahin.ikbal
Advocate
Advocate

It's crashing while updating    this.Elbow

0 Likes
Message 3 of 3

sahin.ikbal
Advocate
Advocate
Accepted solution

Sorry for bothering it was a simple mistake of reassigning property value itself to itself.

0 Likes