# Closed polyline from hatch

**URL:** <https://forum.dynamobim.com/t/closed-polyline-from-hatch/83309>\
**Category:** Civil 3D\
**Tags:** dynamo\
**Created:** [November 21, 2022, 8:30am UTC](https://forum.dynamobim.com/t/closed-polyline-from-hatch/83309 "2022-11-21T08:30:18Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![C.N.v.d.Zwaag](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/c.n.v.d.zwaag/32/128737_2.png) [@C.N.v.d.Zwaag](https://forum.dynamobim.com/u/C.N.v.d.Zwaag)\
**Post date:** [November 21, 2022, 8:30am UTC](https://forum.dynamobim.com/t/closed-polyline-from-hatch/83309/1 "2022-11-21T08:30:18Z")

</div>

Hello all,  
Sorry for the bad english. I was hoping to automatically get multiple closed polylines from excisting hatches. In civil or autocad its of course posibble to use: generate boundary, but i cant seem to find this option in dynamo.

---

<div class="post-metadata">

**Author:** ![Vladimir](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/vladimir/32/147600_2.png) [@Vladimir](https://forum.dynamobim.com/u/Vladimir)\
**Post date:** [November 21, 2022, 9:55am UTC](https://forum.dynamobim.com/t/closed-polyline-from-hatch/83309/2 "2022-11-21T09:55:47Z")

</div>

@C.N.v.d.Zwaag try:

> [@Get Hatch Boundary from Autocad](https://forum.dynamobim.com/t/get-hatch-boundary-from-autocad/68863/6):
>
> here a simple example without arc (no need to get bulges) [getBoundary hatch3] code IronPython import sys import clr import System from System import \* clr.AddReference('ProtoGeometry') from Autodesk.DesignScript.Geometry import \* from math import tan, radians from System import Array errorAcd = None try: import System.Runtime.InteropServices #import Autodesk.AutoCAD.Interop app = System.Runtime.InteropServices.Marshal.GetActiveObject("Autocad.Application") try: clr.AddReference('Autod…

---

<div class="post-metadata">

**Author:** ![mzjensen](https://avatars.discourse-cdn.com/v4/letter/m/b77776/32.png) [@mzjensen](https://forum.dynamobim.com/u/mzjensen)\
**Post date:** [November 21, 2022, 2:20pm UTC](https://forum.dynamobim.com/t/closed-polyline-from-hatch/83309/3 "2022-11-21T14:20:09Z")

</div>

Hi @C.N.v.d.Zwaag,

Take a look at the Civil 3D Toolkit package. There is a node to get the polycurve boundary of a hatch. It is not necessary to use Python.

---

<div class="post-metadata">

**Author:** ![C.N.v.d.Zwaag](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/c.n.v.d.zwaag/32/128737_2.png) [@C.N.v.d.Zwaag](https://forum.dynamobim.com/u/C.N.v.d.Zwaag)\
**Post date:** [November 21, 2022, 2:30pm UTC](https://forum.dynamobim.com/t/closed-polyline-from-hatch/83309/4 "2022-11-21T14:30:16Z")

</div>

![hatch-boundary](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/8/f85fd0aac7e886ceae51d643200a3bd9d64e7618.png)

Yes i saw that C3D toolkit had this package, I am trying to use this node but it places the polylines miles away from where the actual hatch is located. maybe im doing something wrong in the filter part, but im not ceirtain.

thanks for the help btw 😃

---

<div class="post-metadata">

**Author:** ![mzjensen](https://avatars.discourse-cdn.com/v4/letter/m/b77776/32.png) [@mzjensen](https://forum.dynamobim.com/u/mzjensen)\
**Post date:** [November 21, 2022, 3:37pm UTC](https://forum.dynamobim.com/t/closed-polyline-from-hatch/83309/5 "2022-11-21T15:37:45Z")

</div>

You are getting the hatches within block definitions, which have coordinate systems that do not correspond with the WCS. Are the desired hatches contained within block references or just in model space?

---

<div class="post-metadata">

**Author:** ![C.N.v.d.Zwaag](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/c.n.v.d.zwaag/32/128737_2.png) [@C.N.v.d.Zwaag](https://forum.dynamobim.com/u/C.N.v.d.Zwaag)\
**Post date:** [November 22, 2022, 7:01am UTC](https://forum.dynamobim.com/t/closed-polyline-from-hatch/83309/6 "2022-11-22T07:01:29Z")

</div>

These hatches are located in the model space. so this might cause the problem.

---

<div class="post-metadata">

**Author:** ![mzjensen](https://avatars.discourse-cdn.com/v4/letter/m/b77776/32.png) [@mzjensen](https://forum.dynamobim.com/u/mzjensen)\
**Post date:** [November 22, 2022, 2:31pm UTC](https://forum.dynamobim.com/t/closed-polyline-from-hatch/83309/7 "2022-11-22T14:31:51Z")

</div>

OK, in that case then the only input you should have for ‘block’ is the model space block.

_Document.Current_ → _Document.ModelSpace_

---

<div class="post-metadata">

**Author:** ![C.N.v.d.Zwaag](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/c.n.v.d.zwaag/32/128737_2.png) [@C.N.v.d.Zwaag](https://forum.dynamobim.com/u/C.N.v.d.Zwaag)\
**Post date:** [November 22, 2022, 2:45pm UTC](https://forum.dynamobim.com/t/closed-polyline-from-hatch/83309/8 "2022-11-22T14:45:12Z")

</div>

Yes it works. but it only does when the hatches are created by using the select function not the pick points function 😕  
The information in Hatch.ByObject turns these hatches to: hatch(Loop=0) is there any solution to get the hatch object even if the hatch is created while its created by pick point(s)?

---

<div class="post-metadata">

**Author:** ![mzjensen](https://avatars.discourse-cdn.com/v4/letter/m/b77776/32.png) [@mzjensen](https://forum.dynamobim.com/u/mzjensen)\
**Post date:** [November 22, 2022, 3:20pm UTC](https://forum.dynamobim.com/t/closed-polyline-from-hatch/83309/9 "2022-11-22T15:20:02Z")

</div>

Not sure I understand. Can you show an example?

---

<div class="post-metadata">

**Author:** ![C.N.v.d.Zwaag](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/c.n.v.d.zwaag/32/128737_2.png) [@C.N.v.d.Zwaag](https://forum.dynamobim.com/u/C.N.v.d.Zwaag)\
**Post date:** [November 22, 2022, 3:26pm UTC](https://forum.dynamobim.com/t/closed-polyline-from-hatch/83309/10 "2022-11-22T15:26:47Z")

</div>

![pick or select](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/0/707764286c1245caa7613261c948ec2390098fa0.png)

 ![dynamo](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/1/715e2d09ff61462d32c9e45b28c49342125077f4.png)  
So where you see the loops=0, these are hatches that are made with the pick points tool(see first picture)  
the ones that work and return a closed polyline, the ones with a loop=1. these are made with the select tool also in picture 1.

---

<div class="post-metadata">

**Author:** ![darren212176](https://avatars.discourse-cdn.com/v4/letter/d/e495f1/32.png) [@darren212176](https://forum.dynamobim.com/u/darren212176)\
**Post date:** [December 15, 2022, 11:51pm UTC](https://forum.dynamobim.com/t/closed-polyline-from-hatch/83309/11 "2022-12-15T23:51:40Z")

</div>

I also encountered the same problem, with the “pick points” method for hatch creation, the “hatch.byobject” returns loop=0

---

<div class="post-metadata">

**Author:** ![mzjensen](https://avatars.discourse-cdn.com/v4/letter/m/b77776/32.png) [@mzjensen](https://forum.dynamobim.com/u/mzjensen)\
**Post date:** [December 21, 2022, 4:52am UTC](https://forum.dynamobim.com/t/closed-polyline-from-hatch/83309/12 "2022-12-21T04:52:24Z")

</div>

FYI @Paolo_Emilio_Serra1

---

<div class="post-metadata">

**Author:** ![Gamalabubakrr](https://avatars.discourse-cdn.com/v4/letter/g/d26b3c/32.png) [@Gamalabubakrr](https://forum.dynamobim.com/u/Gamalabubakrr)\
**Post date:** [March 17, 2023, 5:16pm UTC](https://forum.dynamobim.com/t/closed-polyline-from-hatch/83309/13 "2023-03-17T17:16:23Z")

</div>

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/8/8875a65b8d50bfad4f10fb879456b449c1b83524.png)  
Its not working with curved hatch even when adding polycurve.curves.  
Any Help please?

---

<div class="post-metadata">

**Author:** ![Koz\_Jono\_Yeoh](https://avatars.discourse-cdn.com/v4/letter/k/7ea924/32.png) [@Koz\_Jono\_Yeoh](https://forum.dynamobim.com/u/Koz_Jono_Yeoh)\
**Post date:** [March 18, 2023, 2:36am UTC](https://forum.dynamobim.com/t/closed-polyline-from-hatch/83309/14 "2023-03-18T02:36:52Z")

</div>

Better regenerate the boundary inside AutoCAD and place them into a particular layer, then can use dynamo to pick them up from that layer.  
hatch made via picking inside point is a boundary-associated hatch which may not have a “real” closed boundary curve. I do not think the dynamo code can rebuild the closed boundary curves (if has holes or multiple closed boundaries) well, better use CAD to do that job.
