Hatch pattern
Moderators: SDS, support, admin
Hatch pattern
Hello,
I would like to create thematic. So i need to create new hatchs in a new layer.
Support send me previously the following code. But according to dwg file and with same code, hatch pattern are totally filled or partially fill by line.
I need pattern partially fill by line but no totally filled (solid) because entities of others layers would be hidden.
Please, How can i correct these code :
private void btnAddHatchOnPolylinePoints_Click(object sender, System.EventArgs e)
{
if(this.cadImage == null)
{
this.cadImage = new CADImage();
this.cadImage.InitialNewImage();
this.cadImage.UseDoubleBuffering = false;
}
this.cadImage.UseDoubleBuffering = false;
CADLayer entLayer = new CADLayer();
entLayer.Name = "MyLayer";
entLayer.Color = Color.RoyalBlue;
entLayer.Visibility = true;
this.cadImage.Converter.Layers.Add(entLayer);
this.cadImage.Converter.OnCreate(entLayer);
this.cadImage.Converter.Loads(entLayer);
for(int i=0;i<this.cadImage.Converter.GetCounts(CADImport.FaceModule.ConvSection.Entities);i++)
{
if(this.cadImage.Converter.GetSection(CADImport.FaceModule.ConvSection.Entities).Entities is
CADPolyLine)
{
CADPolyLine entPolyline =
(CADPolyLine)this.cadImage.Converter.GetSection(CADImport.FaceModule.ConvSection.Entities).Entities;
CADHatch Hatch = new CADHatch();
Hatch.HatchName = "ANSI31";
Hatch.Layer = entLayer;
CAD2DBoundaryList v2DBList = new CAD2DBoundaryList();
v2DBList.BoundaryType = 7;// Polyline type
Hatch.BoundaryData.Add(v2DBList);
CAD2DPolyline v2DPolyline = new CAD2DPolyline();
v2DBList.Add(v2DPolyline);
CAD2DPoint entPoint;
CADVertex entVertex;
for(int j=0;j<entPolyline.Entities.Count;j++)
{
entVertex = (CADVertex)entPolyline.Entities[j];
entPoint = new CAD2DPoint(entVertex.Point.X,entVertex.Point.Y);
v2DPolyline.Vertexes.Add(entPoint); }
v2DPolyline.Closed = true;
Hatch.Color = Color.Azure;
HatchPatternData vHPData = new HatchPatternData();
vHPData.baseP = new DPoint(0, 0, 0);
vHPData.offset = new DPoint(2, 2, 0);
vHPData.lineAngle = 40.0f;
vHPData.isDash = false;
vHPData.lines = null;
vHPData.dashNum = 0;
Hatch.HatchPatternData.Add(vHPData);
Hatch.Loaded(this.cadImage.Converter);
this.cadImage.CurrentLayout.Entities.Add(Hatch);
this.cadImage.Converter.OnCreate(Hatch);
this.cadPictBox.Invalidate();
}
}
this.ResizeLayout();
this.cadPictBox.Invalidate();
}
yannick.
I would like to create thematic. So i need to create new hatchs in a new layer.
Support send me previously the following code. But according to dwg file and with same code, hatch pattern are totally filled or partially fill by line.
I need pattern partially fill by line but no totally filled (solid) because entities of others layers would be hidden.
Please, How can i correct these code :
private void btnAddHatchOnPolylinePoints_Click(object sender, System.EventArgs e)
{
if(this.cadImage == null)
{
this.cadImage = new CADImage();
this.cadImage.InitialNewImage();
this.cadImage.UseDoubleBuffering = false;
}
this.cadImage.UseDoubleBuffering = false;
CADLayer entLayer = new CADLayer();
entLayer.Name = "MyLayer";
entLayer.Color = Color.RoyalBlue;
entLayer.Visibility = true;
this.cadImage.Converter.Layers.Add(entLayer);
this.cadImage.Converter.OnCreate(entLayer);
this.cadImage.Converter.Loads(entLayer);
for(int i=0;i<this.cadImage.Converter.GetCounts(CADImport.FaceModule.ConvSection.Entities);i++)
{
if(this.cadImage.Converter.GetSection(CADImport.FaceModule.ConvSection.Entities).Entities is
CADPolyLine)
{
CADPolyLine entPolyline =
(CADPolyLine)this.cadImage.Converter.GetSection(CADImport.FaceModule.ConvSection.Entities).Entities;
CADHatch Hatch = new CADHatch();
Hatch.HatchName = "ANSI31";
Hatch.Layer = entLayer;
CAD2DBoundaryList v2DBList = new CAD2DBoundaryList();
v2DBList.BoundaryType = 7;// Polyline type
Hatch.BoundaryData.Add(v2DBList);
CAD2DPolyline v2DPolyline = new CAD2DPolyline();
v2DBList.Add(v2DPolyline);
CAD2DPoint entPoint;
CADVertex entVertex;
for(int j=0;j<entPolyline.Entities.Count;j++)
{
entVertex = (CADVertex)entPolyline.Entities[j];
entPoint = new CAD2DPoint(entVertex.Point.X,entVertex.Point.Y);
v2DPolyline.Vertexes.Add(entPoint); }
v2DPolyline.Closed = true;
Hatch.Color = Color.Azure;
HatchPatternData vHPData = new HatchPatternData();
vHPData.baseP = new DPoint(0, 0, 0);
vHPData.offset = new DPoint(2, 2, 0);
vHPData.lineAngle = 40.0f;
vHPData.isDash = false;
vHPData.lines = null;
vHPData.dashNum = 0;
Hatch.HatchPatternData.Add(vHPData);
Hatch.Loaded(this.cadImage.Converter);
this.cadImage.CurrentLayout.Entities.Add(Hatch);
this.cadImage.Converter.OnCreate(Hatch);
this.cadPictBox.Invalidate();
}
}
this.ResizeLayout();
this.cadPictBox.Invalidate();
}
yannick.
Re: Hatch pattern
Hello Yannick,
1. Do you need to have another hatch pattern?
2. Do you need to be filled just a part of the area defined by entPolyline in the code above?
Sergey.
1. Do you need to have another hatch pattern?
2. Do you need to be filled just a part of the area defined by entPolyline in the code above?
Sergey.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
Re: Hatch pattern
Hello Sergey,
1. I need only one hatch pattern that have same visual effect for every file dwg.
Currently for same code, visual effect is different according file dwg.
2. I think i explained badly my problem, so i add two screenshots : one with line pattern and one with pattern totaly filled.
I need visual effet of hatch pattern with line diagonal, i don't want hatch pattern 100% filled.
And I join dwg file where filled pattern happend.
1. I need only one hatch pattern that have same visual effect for every file dwg.
Currently for same code, visual effect is different according file dwg.
2. I think i explained badly my problem, so i add two screenshots : one with line pattern and one with pattern totaly filled.
I need visual effet of hatch pattern with line diagonal, i don't want hatch pattern 100% filled.
And I join dwg file where filled pattern happend.
- Attachments
-
- patternLine.JPG (61.51 KiB) Viewed 38913 times
-
- patternTotallyFill.JPG (20.03 KiB) Viewed 38911 times
Re: Hatch pattern
Hello!
Also we have a question accordingly to this point. Do you need to delete solid filling and to replace it by diagonal lines?
Sergey.
This is impossible by definitions. It is not the fact that all your files have the same size. When viewing some bigger file then others, the hatch will be displayed more crowded then if small image is viewed.1. I need only one hatch pattern that have same visual effect for every file dwg.
Currently for same code, visual effect is different according file dwg.
Could you please send us your DWG file to support@cadsofttools.com. We are afraid it was not added to your post.2. I think i explained badly my problem, so i add two screenshots : one with line pattern and one with pattern totaly filled.
I need visual effet of hatch pattern with line diagonal, i don't want hatch pattern 100% filled.
And I join dwg file where filled pattern happend.
Also we have a question accordingly to this point. Do you need to delete solid filling and to replace it by diagonal lines?
Sergey.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
Re: Hatch pattern
Is it a way to create a layer , add it hach entities and avoid hach entities could be selectable by mouse click?
I create hach entities over CADPolyligne but i would like allow user to select CADPolyline. Currently when i click i select CADHatch.
Can i modify a layer of dwg file in order these entities aren't selectable?
I create hach entities over CADPolyligne but i would like allow user to select CADPolyline. Currently when i click i select CADHatch.
Can i modify a layer of dwg file in order these entities aren't selectable?
Re: Hatch pattern
Hello!
Please find the following method in the demo Viewer:
and replace:
with:
Sergey.
Please find the following method in the demo Viewer:
Code: Select all
public bool SelectEntity(int x, int y)
Code: Select all
CADEntity ent = cadImage.SelectExt(x, y, ! cntrlDown, true);
Code: Select all
CADEntity ent = cadImage.SelectExt(x, y, ! cntrlDown, false);
if ((ent != null)&&(ent.EntType == CADImport.EntityType.Hatch))
return false;
ent = cadImage.SelectExt(x, y, ! cntrlDown, true);
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
Re: Hatch pattern
Hello Sergey,
I thank you for your help.
I download last cadimportnet.zip and in ViewerDemo\ViewerMainForm.cs i don't find SelectEntity.
I suppose you thought cadImage.Select(e.X, e.Y).
With your solution CADHatch would not be selected but i can't select other entities under CADHatch without doing another best clic.
I join a screenshot, we can see Text under CADHach.
If zoom out is important as in the screenshot, some time when i clic on text, CADHatch is selected.
So i asked if we can make unselectable (insensible to clic) all entities of a layer by changing properties of layer.
I see we can set 4 to CADLayer.Flag in order to lock the layer but i don't see difference. I don't know exaclty what is lock for a dwg file.
When two graphics are stack exactly at same point of user clic, which graphic is return by SelectExt?
Is order of a layer import in layer list?
Best regards, yannick.
I thank you for your help.
I download last cadimportnet.zip and in ViewerDemo\ViewerMainForm.cs i don't find SelectEntity.
I suppose you thought cadImage.Select(e.X, e.Y).
With your solution CADHatch would not be selected but i can't select other entities under CADHatch without doing another best clic.
I join a screenshot, we can see Text under CADHach.
If zoom out is important as in the screenshot, some time when i clic on text, CADHatch is selected.
So i asked if we can make unselectable (insensible to clic) all entities of a layer by changing properties of layer.
I see we can set 4 to CADLayer.Flag in order to lock the layer but i don't see difference. I don't know exaclty what is lock for a dwg file.
When two graphics are stack exactly at same point of user clic, which graphic is return by SelectExt?
Is order of a layer import in layer list?
Best regards, yannick.
- Attachments
-
- hatchSelection.JPG (67.67 KiB) Viewed 38847 times
Re: Hatch pattern
Hello!
Here goes explanation for Viewer:
In the
line
replace by
Sergey.
Sorry, my fault. This code was for EditorDemo.I download last cadimportnet.zip and in ViewerDemo\ViewerMainForm.cs i don't find SelectEntity.
I suppose you thought cadImage.Select(e.X, e.Y).
Here goes explanation for Viewer:
In the
Code: Select all
private void cadPictBox_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
Code: Select all
if(cadImage.Select(e.X, e.Y))
Code: Select all
CADEntity ent = cadImage.SelectExt(e.X, e.Y, true, false);
if ((ent != null)&&(ent.EntType == CADImport.EntityType.Hatch))
return;
ent = cadImage.SelectExt(e.X, e.Y, true, true);
if(ent != null)
We can sort entities and text will be over the hatch. So it will become selectable. Is this a solution for you?With your solution CADHatch would not be selected but i can't select other entities under CADHatch without doing another best clic.
It will give nothing. Selection logic does not take into account a state of the layer directly. If layer is frosen its entities do not take part in selection process.So i asked if we can make unselectable (insensible to clic) all entities of a layer by changing properties of layer.
The one that is over all the others.When two graphics are stack exactly at same point of user clic, which graphic is return by SelectExt?
Can you please describe it in detail?Is order of a layer import in layer list?
Sergey.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
Re: Hatch pattern
Sergey,
If we can sort all entities over hatch of a layer, it will resolve my problem.
Is order of a layer import in layer list?
-> I make a syntax error, it was in fact : Is order of a layer has importance in layers list?
what is difference if a layer is added at the end of Layers or inserted at first ? Does it change order of selection when i clic with mouse ?
this.cadImage.Converter.Layers.Add(entLayer);
or
this.cadImage.Converter.Layers.Insert(0,entLayer);
If we can sort all entities over hatch of a layer, it will resolve my problem.
Is order of a layer import in layer list?
-> I make a syntax error, it was in fact : Is order of a layer has importance in layers list?
what is difference if a layer is added at the end of Layers or inserted at first ? Does it change order of selection when i clic with mouse ?
this.cadImage.Converter.Layers.Add(entLayer);
or
this.cadImage.Converter.Layers.Insert(0,entLayer);
Re: Hatch pattern
Hello!
Sergey.
Here goes code example:If we can sort all entities over hatch of a layer, it will resolve my problem.
Code: Select all
private void button1_Click(object sender, System.EventArgs e)
{
if(this.cadImage == null)
{
this.cadImage = new CADImage();
this.cadImage.InitialNewImage();
this.cadImage.UseDoubleBuffering = false;
}
this.cadImage.UseDoubleBuffering = false;
int i = 0;
long BottomHandle;
CADEntity vEntity;
CADSortEntsTable SortTable;
ArrayList HandleList;
HandleList = new ArrayList();
SortTable = new CADSortEntsTable();
BottomHandle = Int32.MaxValue;
for (i=0;i<this.cadImage.Converter.GetCounts(CADImport.FaceModule.ConvSection.Entities);i++)
{
vEntity = (CADEntity)this.cadImage.Converter.GetSection(CADImport.FaceModule.ConvSection.Entities).Entities[i];
SortTable.HandlesOld.Add(vEntity.Handle);
if (vEntity is CADGradientPolygon)
HandleList.Add(vEntity);
if (BottomHandle > vEntity.Handle)
BottomHandle = vEntity.Handle;
}
BottomHandle++;
for (i=0;i<this.cadImage.Converter.GetCounts(CADImport.FaceModule.ConvSection.Entities);i++)
{
if (HandleList.IndexOf(this.cadImage.Converter.GetSection(CADImport.FaceModule.ConvSection.Entities).Entities[i]) == -1)
{
vEntity = (CADEntity)this.cadImage.Converter.GetSection(CADImport.FaceModule.ConvSection.Entities).Entities[i];
SortTable.HandlesNew.Add(vEntity.Handle);
vEntity.Handle = BottomHandle + HandleList.Count + i;
}
}
for (i=0;i<HandleList.Count;i++)
{
vEntity = (CADEntity)HandleList[i];
vEntity.Handle = BottomHandle + i;
SortTable.HandlesNew.Add(vEntity.Handle);
}
this.cadImage.Converter.GetSection(CADImport.FaceModule.ConvSection.Tables).AddEntity(SortTable);
this.cadImage.Converter.Loads(SortTable);
this.cadImage.Converter.SortEntities();
this.cadPictBox.Invalidate();
}
Layers' order takes no part in selecting logic.Is order of a layer import in layer list?
-> I make a syntax error, it was in fact : Is order of a layer has importance in layers list?
what is difference if a layer is added at the end of Layers or inserted at first ? Does it change order of selection when i clic with mouse ?
this.cadImage.Converter.Layers.Add(entLayer);
or
this.cadImage.Converter.Layers.Insert(0,entLayer);
Sergey.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support