Layers

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
jimmy7
Posts: 3
Joined: 16 Sep 2010, 11:12

Layers

Post by jimmy7 » 24 Sep 2010, 13:48

Hi,

I have two problems with layers.

The first one :
I have made my own layer form.
In this layer form the user as a check to select the layer on wich he want to add new entities.
How could I select the layer selected by the user? Each time the selected layer is the first one.

The second problem :
Is it possible to freeze a layer and keep it visible ?
I have tried with the SetFreezeLayer instruction but it freeze and hide the layer.

Best regards

Jimmy

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

Re: Layers

Post by support » 24 Sep 2010, 18:31

Hello.
In CAD Import .NET layer used as entity's property: some_entity.Layer = some_layer. If this property not set then entity will be added to layer with null index in layers collection. You can realize some "active layer" member in your code.
Frozen layer can't be visualized.

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

jimmy7
Posts: 3
Joined: 16 Sep 2010, 11:12

Re: Layers

Post by jimmy7 » 27 Sep 2010, 16:26

Thanks for your response,

I have tried to do the layer affectation in your EditorDemo Solution but I don't find where I have to act, and it seems that the EntitiesCreator object have no Layer properties.

Could you give me a short sample based on your editordemo on how I could do that.

Could you explain me how work the EntitiesCreator class to ? because your documentation is too poor and the EditorDemo Sample has no comment on this subject.

Thanks

Jimmy.

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

Re: Layers

Post by support » 30 Sep 2010, 17:58

Hello.
EntitiesCreator class designed for visual entities creation. Created entity will be placed at CADImage.Converter.Entities collection. Layer can be set for entity at this collection but not for EntitiesCreator.
Please learn the using EntitiesCreator in EditorDemo source. In short you need set class members Image, Enabled and Type (the last two can be set by EnableCreator method). Entity will be drawn on MouseDown event when EntitiesCreator.Enabled is true.

Alexander.

jimmy7
Posts: 3
Joined: 16 Sep 2010, 11:12

Re: Layers

Post by jimmy7 » 01 Oct 2010, 18:02

Hello Alexander,

Your answer is incomprehensible.
I passed one week on the EditorDemoSource and I cannot always say how are created the entities.

So, this is what I understand.

It seems effectively that the operation of begin / end creation are sent by the cadPictBox_MouseDown function.
But, in your last answer you've said "Entity will be drawn on MouseDown event when EntitiesCreator.Enabled is true."
Ok, but HOW ? The only thing I saw is a call to EnableNewEntityCreator.
At least it seems that the first call of this.entCreator.EnableCreator(seltp) in EnableNewEntityCreator is equivalent to a BeginEntity and a second call to the same function is equivalent to a EndEntity.
Could you confirm that ?
However if I look at CADImage.Converter.Entities in EnableNewEntityCreator the item count number did not change. But later in EndAddEntity the item counted has changed.
So, I have made some different test and I could see that the last item in the collection CADImage.Converter.Entities was always the last created.
Could you confirm that ?

So to change the layer of the new entities I have modified the EndAddEntity function like this

Code: Select all

  public void EndAddEntity(bool val) {
   if (curAddEntityType != CreatorType.Undetected) {
    SetAddEntityMode(curAddEntityType);
    CADEntity newestEntity = cadImage.Converter.Entities[(cadImage.Converter.Entities.Count - 1)];
    newestEntity.Color = currentLayer.Color;
    newestEntity.Layer = currentLayer;
    SetEnableChecked();
    ChangeControlState();
   }
   this.detMouseDown = val;
  }
And it works. Can you confirm me that I use the good method ?

Best Regards

Jimmy

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

Re: Layers

Post by support » 04 Oct 2010, 16:59

Hello Jimmy.
The EnableNewEntityCreator is the demo application method that calls EnableCreator with entity type that was chosen on form. EnableCreator not equivalent to BeginEntity/EndEntity but set required parameters (Enabled and Type properties). BeginEntity/EndEntity rely upon MouseDown event and require these properties to be set.
Also CADImage.Converter.Entities will be changed after BeginEntity start, EnableNewEntityCreator can't change this collection. You're correct, the last item in the collection CADImage.Converter.Entities was always the last created.
Again, EndAddEntity is the demo application method. You can modify it to set layer in entities collection and your modification is correct, but you can't set layer with EntitiesCreator object.

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

Post Reply