Create Hatch in Outer Block and exclude inner block

Create Hatch in Outer Block and exclude inner block

saikiran.nT432F
Participant Participant
428 Views
1 Reply
Message 1 of 2

Create Hatch in Outer Block and exclude inner block

saikiran.nT432F
Participant
Participant

Hi All,

 

I have a requirement where i want to craete hatch only for the outer block and need exclude the inner block. I have tried the following steps but none worked so far.

 

1.  Hatchstyle enum as shown in example of below link

https://help.autodesk.com/view/OARX/2024/ENU/?guid=GUID-01A47A4F-9FC5-4DB6-8C3E-B72D75688965

hatch.HatchStyle = HatchStyle.Outer;

                  (or)

hatch.HatchStyle = HatchStyle.Normal;

 

2. Create Hatch for Outer block and remove hatch in inner block (instead of blocks also tried for polyline)

 

3. Tried to achieve with below code 

 

Hatch hatch = new Hatch();
hatch.SetDatabaseDefaults();
hatch.SetHatchPattern(HatchPatternType.PreDefined, "ANGLE");
hatch.PatternScale = 1;
hatch.AppendLoop(HatchLoopTypes.Outermost, new ObjectIdCollection { polyline.ObjectId });

ObjectId hatchId = modelSpace.AppendEntity(hatch);
tr.AddNewlyCreatedDBObject(hatch, true);

 

Your ideas and response on this matter is highly appreciated. Thanks in advance.

0 Likes
429 Views
1 Reply
Reply (1)
Message 2 of 2

ActivistInvestor
Mentor
Mentor

@saikiran.nT432F wrote:

Hi All,

 

I have a requirement where i want to craete hatch only for the outer block and need exclude the inner block. I have tried the following steps but none worked so far.

 

1.  Hatchstyle enum as shown in example of below link

https://help.autodesk.com/view/OARX/2024/ENU/?guid=GUID-01A47A4F-9FC5-4DB6-8C3E-B72D75688965

hatch.HatchStyle = HatchStyle.Outer;

                  (or)

hatch.HatchStyle = HatchStyle.Normal;

 

2. Create Hatch for Outer block and remove hatch in inner block (instead of blocks also tried for polyline)

 

3. Tried to achieve with below code 

 

Hatch hatch = new Hatch();
hatch.SetDatabaseDefaults();
hatch.SetHatchPattern(HatchPatternType.PreDefined, "ANGLE");
hatch.PatternScale = 1;
hatch.AppendLoop(HatchLoopTypes.Outermost, new ObjectIdCollection { polyline.ObjectId });

ObjectId hatchId = modelSpace.AppendEntity(hatch);
tr.AddNewlyCreatedDBObject(hatch, true);

 

Your ideas and response on this matter is highly appreciated. Thanks in advance.


 

You need to read the documentation better, and look at the example it includes, because it clearly outlines what steps you must take. What the docs don't explicitly mention is that you must add the hatch to the database and transaction first, before you take any further steps.

 

The code you show above does not call AppendLoop() to add the inner loop(s) to the hatch (after adding the outer loop), and also does not call EvaluateHatch()

 

 

0 Likes