Can't select entity after overrule

Can't select entity after overrule

BrentBurgess1980
Collaborator Collaborator
726 Views
3 Replies
Message 1 of 4

Can't select entity after overrule

BrentBurgess1980
Collaborator
Collaborator

Hi all,

 

I am creating a plugin for a project that will allow users to display polylines etc as 3d solids using the overrule by apply xdata with the radius.

 

Works fine on the most part, but on the occasion that a swept solid can't create, I want the overrule to be disabled (I have already got the xdata being removed working).

 

 

public override bool WorldDraw(Drawable d, WorldDraw wd)
            {
            double radius = 0.0;

            if (d is DBObject)
                radius = GetPipeRadius((DBObject)d);

            if (radius > 0.0)
                {
                Polyline pline = d as Polyline;

                if (pline != null)
                    {
                    Solid3D sol = GeometryServices.CreatePipe((Entity)pline, radius);

                    if (!sol.Created) // this is a property in my inherited solid3d class
                        return false;
                    
                    base.WorldDraw(pline, wd);
                    
                    short c = wd.SubEntityTraits.Color;
                    wd.SubEntityTraits.Color = GeometryServices.GetColour(pline.Layer);
                    wd.SubEntityTraits.LineWeight = LineWeight.ByLineWeightDefault;

                    sol.WorldDraw(wd);
                    sol.Dispose();
                    wd.SubEntityTraits.Color = c;
                    return true;

                    }
                }
            return base.WorldDraw(d, wd);
            }

 

Currently the code executes, but after (if the solid doesn't create), I am not able to select the polyline. No grips are shown, wont show in properties, can't list it. After I do an audit, it is back to normal.

 

Can anyone see how I can do this? happy to provide more code if needed.

 

Cheers,

 

Brent 

 

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

norman.yuan
Mentor
Mentor

It looks like XData filter to the overruled entities is not enough and you need further filtering, which you do it in the WorldDraw() override. More logic approach would be to use customFilter and override IsApplicable() and make a thorough filtering before the overrule applies. That is, you do not call

 

SetXDataFilrer(sring)

 

instead, you call

 

SetCustomFilter()

 

and then write code in IsApplicable() to find out if the polyline has particular XData attached and if it has 0 radius.

 

With that said, from you code, it seems that you need to place

 

return base.WorldDraw(d,wd)

 

in the "else..." clause. That is, if radius > 0.0, then you want draw solid, otherwise, still draw polyline. You currently leave "return base.WorldDraw() outside the "if..." statement, so it is always called (thus the polyline is always drawn, in spite of a solid may have already been drawn.

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 3 of 4

BrentBurgess1980
Collaborator
Collaborator

Thanks Norman. I'll work through that and see how I go.

0 Likes
Message 4 of 4

BrentBurgess1980
Collaborator
Collaborator
Accepted solution

I found that I had the SetXdataFilter in my derived base class, but the real problem was that if the solid wasn't created, I was trying to remove the XData, and once the XData was removed it didnt function properly. I removed that line and it worked well.

 

Thanks for the help!!

 

0 Likes