Unable to see newly created layer while clicking Show Layers
Moderators: SDS, support, admin
Unable to see newly created layer while clicking Show Layers
Hello,
I am trying to add layer to CADPictureBox.
cadImage = this.CADPictureBox.Image;
CADLayer l = new CADLayer()
{
Name = "Test",
Visibility = true
};
l.Loaded(this.cadImage.Converter);
this.cadImage.Converter.Layers.Add(l);
cadImage.Converter.OnCreate(l);
CADLine xLine = new CADLine();
xLine.Point = new DPoint(10, 10, 0);
xLine.Point1 = new DPoint(70, 20, 0);
xLine.Color = System.Drawing.Color.Red;
xLine.LineWeight = Convert.ToSingle(10);
cadImage.Converter.GetSection(ConvSection.Entities).AddEntity(xLine);
cadImage.Converter.OnCreate(xLine);
cadImage.Converter.Loads(xLine);
xLine.Layer = l;
this.CADPictureBox.InvalidateImage();
When I run following code
for (int i = 0; i < this.CADPictureBox.Image.Converter.GetSection(CADImport.FaceModule.ConvSection.Layers).Count; i++)
S = S + ((CADLayer)this.CADPictureBox.Image.Converter.Layers).Name + ", ";
System.Windows.MessageBox.Show("Layers count: " + this.CADPictureBox.Image.Converter.Layers.Count + " " + S);
I can see newly created layer, but if I click "Show Layers" menu button I cannot see new layer in the list. I use cadimport.dll v 12.0.20.20525
Am I doing something wrong?
I am trying to add layer to CADPictureBox.
cadImage = this.CADPictureBox.Image;
CADLayer l = new CADLayer()
{
Name = "Test",
Visibility = true
};
l.Loaded(this.cadImage.Converter);
this.cadImage.Converter.Layers.Add(l);
cadImage.Converter.OnCreate(l);
CADLine xLine = new CADLine();
xLine.Point = new DPoint(10, 10, 0);
xLine.Point1 = new DPoint(70, 20, 0);
xLine.Color = System.Drawing.Color.Red;
xLine.LineWeight = Convert.ToSingle(10);
cadImage.Converter.GetSection(ConvSection.Entities).AddEntity(xLine);
cadImage.Converter.OnCreate(xLine);
cadImage.Converter.Loads(xLine);
xLine.Layer = l;
this.CADPictureBox.InvalidateImage();
When I run following code
for (int i = 0; i < this.CADPictureBox.Image.Converter.GetSection(CADImport.FaceModule.ConvSection.Layers).Count; i++)
S = S + ((CADLayer)this.CADPictureBox.Image.Converter.Layers).Name + ", ";
System.Windows.MessageBox.Show("Layers count: " + this.CADPictureBox.Image.Converter.Layers.Count + " " + S);
I can see newly created layer, but if I click "Show Layers" menu button I cannot see new layer in the list. I use cadimport.dll v 12.0.20.20525
Am I doing something wrong?
Re: Unable to see newly created layer while clicking Show La
Hello,
CADLayer is normally added to a specified CADImage instance, not to CADPictureBox, so the sentence I am trying to add layer to CADPictureBox is not correct. CADPictureBox doesn't have Image property and InvalidateImage() method that makes your code not compilable.
Let's assume that your code is compilable by replacing this.CADPictureBox.Image field with this.cadImage and commenting out the line
After that let's take a look at the handler for "Show Layers" menu button, it invokes SetLayList() method which actually fills the layers list:
This method adds new records to the layers list only when the list is empty (Items.Count == 0), in other words, it doesn't refresh the existing list of layers. The given fact explains why you cannot see a new layer in this list.
To see newly created layers, you may try to clear the existing list if it's not empty and fill it all over again:
Mikhail
CADLayer is normally added to a specified CADImage instance, not to CADPictureBox, so the sentence I am trying to add layer to CADPictureBox is not correct. CADPictureBox doesn't have Image property and InvalidateImage() method that makes your code not compilable.
Let's assume that your code is compilable by replacing this.CADPictureBox.Image field with this.cadImage and commenting out the line
Code: Select all
this.CADPictureBox.InvalidateImage();
Code: Select all
private void SetLayList()
{
if ((lForm.LayerList.Items.Count != 0) || (cadImage == null))
return;
...
}
To see newly created layers, you may try to clear the existing list if it's not empty and fill it all over again:
Code: Select all
private void SetLayList()
{
if (cadImage == null)
return;
if (lForm.LayerList.Items.Count != 0)
lForm.LayerList.Clear();
...
}
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support