Selection

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
yannick
Posts: 18
Joined: 16 Apr 2008, 12:43

Selection

Post by yannick » 17 Jun 2008, 16:45

Hello,

I use CADImport.net and framework .net 2.0.
I work on selection of entities in a dwg file and i get following errors.

-I use original code of source demo ViewerMainForm.cs, in cadPictBox_MouseDown() i want to get selected entities so i add the following line but i get exception "Failed to compare two elements in the array":
CADEntity entEntity = (CADEntity)cadImage.SelectedEntities[0];

-I don't manage to clear drawing of previous selection make by code.
I make a fonction that manage selection. This fonction get list of entities, first it clear previous selection and after it make new selection.
protected void SelectedEntities(CADEntityCollection lstCADEnt)
{
this.cadImage.ClearSelection();
cadImage.ClearBuffer();
cadImage.SelectedEntities.Clear();
if ( lstCADEnt.Count >0)
cadImage.DoSelectEntities(lstCADEnt);
cadPictBox.Invalidate(cadImage.GetSelectEntityRegion(this.cadPictBox.ClientRectangle));
}

When i call the fonction first time, it works, entities appears as selected.
When i call the fonction second time with other list of entities, new entites are selected but previous entities stay selected.
Even if i click to empty zone in map then cadPictBox_MouseDown is call but don't clear drawing of previous selection done by code.
More over if i call the number of entities selected, i always get 0 :
int i = cadImage.SelectEntitiesCount;

-How can i zoom on selected entities ( zoom on selection)?

-How can i make visible selected entities on center of the screen (center on selection)?

-Is CADImport.net working with floating license?

-In a dwg file, DWG TrueView show layout with some layer hide. Where as CADImport show layout with all layers.
Move over CADImport show all data present in the region of the layout where as DWG TrueView show only data that were define as show in the layout.
Does CADImport.net know correctly interpret layout and hide data/layer not present in layout or CADImport just take the area of the layout and show all ?

Best regards, yannick

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: Selection

Post by support » 17 Jun 2008, 17:11

Hello yannick,

We will answe you soon.

Sergey.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: Selection

Post by support » 18 Jul 2008, 17:41

Hello!
-I use original code of source demo ViewerMainForm.cs, in cadPictBox_MouseDown() i want to get selected entities so i add the following line but i get exception "Failed to compare two elements in the array":
CADEntity entEntity = (CADEntity)cadImage.SelectedEntities[0];

-I don't manage to clear drawing of previous selection make by code.
I make a fonction that manage selection. This fonction get list of entities, first it clear previous selection and after it make new selection.
protected void SelectedEntities(CADEntityCollection lstCADEnt)

Code: Select all

{
     this.cadImage.ClearSelection();
     cadImage.ClearBuffer();
     cadImage.SelectedEntities.Clear();
     if ( lstCADEnt.Count >0)
          cadImage.DoSelectEntities(lstCADEnt);
     cadPictBox.Invalidate(cadImage.GetSelectEntityRegion(this.cadPictBox.ClientRectangle));
}
When i call the fonction first time, it works, entities appears as selected.
When i call the fonction second time with other list of entities, new entites are selected but previous entities stay selected.
Even if i click to empty zone in map then cadPictBox_MouseDown is call but don't clear drawing of previous selection done by code.
More over if i call the number of entities selected, i always get 0 :
int i = cadImage.SelectEntitiesCount;
We would recommend to try the follwoing code:

Code: Select all

        protected void UserClearEntities(CADEntityCollection lstCADEnt)
        {
            cadImage.UndoSelect();
            for (int i = 0; i < lstCADEnt.Count; i++)
            {
                CADEntity vEntity = lstCADEnt[i];
                vEntity.Selected = true;
                CADImportFace.SelectObject(vEntity);
                if (vEntity.KeyEnt != null)
                    cadImage.SelectedEntities.Add(vEntity.KeyEnt, vEntity);
            }
            cadPictBox.Invalidate(cadImage.GetSelectEntityRegion(this.cadPictBox.ClientRectangle));
        } 
-How can i zoom on selected entities ( zoom on selection)?

-How can i make visible selected entities on center of the screen (center on selection)?
Here goes code example how to zoom on entities:

Code: Select all

private float SetNewScale(Point topLeft, Point bottomRight)
{
	Rectangle entRect = new Rectangle(topLeft.X - 2, topLeft.Y - 2, (bottomRight.X - topLeft.X) + 4, (bottomRight.Y - topLeft.Y) + 4);               
	float kf1 = (this.curClRect.Width * scale) / entRect.Width;
	float kf2 = (this.curClRect.Height * scale) / entRect.Height;     
	if(kf1 > kf2)
		kf1 = kf2;                                   
	return kf1;
}

private int cnt_ent = 0;

private void btnShowRect_Click(object sender, System.EventArgs e)
{     
	this.cadImage.UseDoubleBuffering = false;
	cadPictBox.Invalidate();			

	if(cnt_ent >= this.cadImage.Converter.Entities.Count)
		cnt_ent = 0;
	CADEntity ent = this.cadImage.Converter.Entities[cnt_ent];
	Point topLeft = this.cadImage.GetPoint(ent.Box.TopLeft);               
	Point bottomRight = this.cadImage.GetPoint(ent.Box.BottomRight);          
	//shift----------               
	float centerX = this.curClRect.Width / 2.0f - (bottomRight.X - topLeft.X) / 2.0f;
	float centerY = this.curClRect.Height / 2.0f - (bottomRight.Y - topLeft.Y) / 2.0f;                                                                 
	this.pos.X = this.pos.X - topLeft.X + centerX;          
	this.pos.Y = this.pos.Y - topLeft.Y + centerY;                                        
	//--------------     
	old_Pos = new PointF(cadPictBox.ClientRectangle.Width / 2, cadPictBox.ClientRectangle.Height / 2);
	this.scale = SetNewScale(topLeft, bottomRight);               
	cadPictBox.Invalidate();               
	cnt_ent++;                              
}
-Is CADImport.net working with floating license?
Currently this functionality is unavailable.

Sergey.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Post Reply