Hatch pattern

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

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

Hatch pattern

Post by yannick » 08 Jul 2008, 20:00

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.

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

Re: Hatch pattern

Post by support » 09 Jul 2008, 12:44

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.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

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

Re: Hatch pattern

Post by yannick » 09 Jul 2008, 16:36

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.
Attachments
patternLine.JPG
patternLine.JPG (61.51 KiB) Viewed 38913 times
patternTotallyFill.JPG
patternTotallyFill.JPG (20.03 KiB) Viewed 38911 times

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

Re: Hatch pattern

Post by support » 11 Jul 2008, 09:59

Hello!
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.
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.
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.
Could you please send us your DWG file to support@cadsofttools.com. We are afraid it was not added to your post.
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

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

Re: Hatch pattern

Post by yannick » 25 Jul 2008, 18:09

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?

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

Re: Hatch pattern

Post by support » 28 Jul 2008, 11:30

Hello!

Please find the following method in the demo Viewer:

Code: Select all

public bool SelectEntity(int x, int y)
and replace:

Code: Select all

CADEntity ent = cadImage.SelectExt(x, y, ! cntrlDown, true);
with:

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);
Sergey.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

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

Re: Hatch pattern

Post by yannick » 28 Jul 2008, 14:46

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.
Attachments
hatchSelection.JPG
hatchSelection.JPG (67.67 KiB) Viewed 38847 times

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

Re: Hatch pattern

Post by support » 29 Jul 2008, 10:42

Hello!
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).
Sorry, my fault. This code was for EditorDemo.
Here goes explanation for Viewer:
In the

Code: Select all

private void cadPictBox_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
line

Code: Select all

if(cadImage.Select(e.X, e.Y))
replace by

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)
With your solution CADHatch would not be selected but i can't select other entities under CADHatch without doing another best clic.
We can sort entities and text will be over the hatch. So it will become selectable. Is this a solution for you?
So i asked if we can make unselectable (insensible to clic) all entities of a layer by changing properties of layer.
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.
When two graphics are stack exactly at same point of user clic, which graphic is return by SelectExt?
The one that is over all the others.
Is order of a layer import in layer list?
Can you please describe it in detail?

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

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

Re: Hatch pattern

Post by yannick » 29 Jul 2008, 12:46

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);

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

Re: Hatch pattern

Post by support » 30 Jul 2008, 14:54

Hello!
If we can sort all entities over hatch of a layer, it will resolve my problem.
Here goes code example:

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();
}
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);
Layers' order takes no part in selecting logic.

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

Post Reply