# Find ngons in Sub-D surface

**URL:** <https://discourse.mcneel.com/t/find-ngons-in-sub-d-surface/189840>\
**Category:** SubD\
**Tags:** windows\
**Created:** [August 21, 2024, 8:06am UTC](https://discourse.mcneel.com/t/find-ngons-in-sub-d-surface/189840 "2024-08-21T08:06:30Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bassie](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/bassie/32/601609_2.png) [@Bassie](https://discourse.mcneel.com/u/Bassie)\
**Post date:** [August 21, 2024, 8:06am UTC](https://discourse.mcneel.com/t/find-ngons-in-sub-d-surface/189840/1 "2024-08-21T08:06:30Z")

</div>

I’m trying to find the ngons in my Sub-D model. I can only find one, but the object description shows there are 3 5-gons.

 ![Screenshot 2024-08-21 100500](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/4/3/2/432076747497a7652b1a298bd363dd4bd9478d12.png)

Is there any command that I can use to find them more easily?

---

<div class="post-metadata">

**Author:** ![Bassie](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/bassie/32/601609_2.png) [@Bassie](https://discourse.mcneel.com/u/Bassie)\
**Post date:** [August 21, 2024, 9:44am UTC](https://discourse.mcneel.com/t/find-ngons-in-sub-d-surface/189840/2 "2024-08-21T09:44:18Z")

</div>

I found a way to narrow the ngons down to part of the mesh:

1. Select a subset of the SubD faces.
2. ExtractSrf on those faces.
3. Look at the object description of the extracted surface and see if there are ngons present.
4. (repeat)

---

<div class="post-metadata">

**Author:** ![martinsiegrist](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/martinsiegrist/32/498369_2.png) [@martinsiegrist](https://discourse.mcneel.com/u/martinsiegrist)\
**Post date:** [August 21, 2024, 9:45am UTC](https://discourse.mcneel.com/t/find-ngons-in-sub-d-surface/189840/3 "2024-08-21T09:45:55Z")

</div>

Can you work with Grasshopper?

---

<div class="post-metadata">

**Author:** ![Trav](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/trav/32/681734_2.png) [@Trav](https://discourse.mcneel.com/u/Trav)\
**Post date:** [August 21, 2024, 5:22pm UTC](https://discourse.mcneel.com/t/find-ngons-in-sub-d-surface/189840/4 "2024-08-21T17:22:54Z")

</div>

This might be helpful. This is a c# script that you can load into the Rhino 8 ScriptEditor and run that will work like a command that marks each mesh or subd ngon center with a text dot displaying its NGon edge count and can optionally mark triangles and quads as well via a command line option.

 ![0746](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/9/e/6/9e621fbc3c8f17594bc57f7dd860308ff222a843.jpeg)  
 ![0748](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/0/9/2/092c19ee37b98ae93c52479daaec92dcae2e6fb4.jpeg)

[MarkNgons.cs](https://discourse.mcneel.com/uploads/short-url/p20aC5qZlx5SkxCoQNDEa4lHim5.cs) (2.0 KB)

---

<div class="post-metadata">

**Author:** ![martinsiegrist](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/martinsiegrist/32/498369_2.png) [@martinsiegrist](https://discourse.mcneel.com/u/martinsiegrist)\
**Post date:** [August 24, 2024, 10:23am UTC](https://discourse.mcneel.com/t/find-ngons-in-sub-d-surface/189840/5 "2024-08-24T10:23:52Z")

</div>

How do you run this in a button? I know `! _-RunPythonScript "script.py"`, is there something similar for c#?

I’ve looked at this page but I can’t find a solution for c#:

[Integrating macros and scripts into your workspace [McNeel Wiki]](https://wiki.mcneel.com/rhino/macroscriptsetup#:~:text=In%20Rhino%2C%20go%20to%20Options%3EAliases%20%28Windows%29%20or%20Preferences%3EAliases,alias%20name%2C%20type%20or%20paste%20in%20your%20macro.)

---

<div class="post-metadata">

**Author:** ![BrianJ](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/brianj/32/751593_2.png) [@BrianJ](https://discourse.mcneel.com/u/BrianJ)\
**Post date:** [August 26, 2024, 12:21pm UTC](https://discourse.mcneel.com/t/find-ngons-in-sub-d-surface/189840/6 "2024-08-26T12:21:26Z")

</div>

Hi @martinsiegrist ,

Use the command -ScriptEditor in Rhino 8 to load and run this one. Then put it in a button like this with your unique path for the file… -ScriptEditor R M:\Scripts\MarkNgons.cs

---

<div class="post-metadata">

**Author:** ![martinsiegrist](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/martinsiegrist/32/498369_2.png) [@martinsiegrist](https://discourse.mcneel.com/u/martinsiegrist)\
**Post date:** [August 26, 2024, 12:25pm UTC](https://discourse.mcneel.com/t/find-ngons-in-sub-d-surface/189840/7 "2024-08-26T12:25:39Z")

</div>

Thanks. It works 🙂

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/6/1/5/615d63e17df7ce6d4bc1acb0478406bf1b2c8267.png)

---

<div class="post-metadata">

**Author:** ![martinsiegrist](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/martinsiegrist/32/498369_2.png) [@martinsiegrist](https://discourse.mcneel.com/u/martinsiegrist)\
**Post date:** [February 26, 2025, 11:16pm UTC](https://discourse.mcneel.com/t/find-ngons-in-sub-d-surface/189840/8 "2025-02-26T23:16:52Z")

</div>

> [@BrianJ](#):
>
> -ScriptEditor R M:\Scripts\MarkNgons.cs

Hi @BrianJ this currently fails. In Rhino 8 it says Compile Error in the command line. In Rhino 9 I get this error message:

```auto
Compile Error
Assuming assembly reference 'System.Drawing.Primitives, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' used by 'RhinoCommon' matches identity 'System.Drawing.Primitives, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' of 'System.Drawing.Primitives', you may need to supply runtime policy (Warning CS1701) file:///:[1:1]
Assuming assembly reference 'System.Drawing.Primitives, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' used by 'Rhino.UI' matches identity 'System.Drawing.Primitives, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' of 'System.Drawing.Primitives', you may need to supply runtime policy (Warning CS1701) file:///:[1:1]

```

---

<div class="post-metadata">

**Author:** ![BrianJ](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/brianj/32/751593_2.png) [@BrianJ](https://discourse.mcneel.com/u/BrianJ)\
**Post date:** [February 27, 2025, 2:10pm UTC](https://discourse.mcneel.com/t/find-ngons-in-sub-d-surface/189840/9 "2025-02-27T14:10:54Z")

</div>

@Trav wrote that one and may have an idea.

---

<div class="post-metadata">

**Author:** ![martinsiegrist](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/martinsiegrist/32/498369_2.png) [@martinsiegrist](https://discourse.mcneel.com/u/martinsiegrist)\
**Post date:** [February 27, 2025, 9:09pm UTC](https://discourse.mcneel.com/t/find-ngons-in-sub-d-surface/189840/10 "2025-02-27T21:09:24Z")

</div>

@Trav it seems that also python scripts in buttons fail to execute at the moment. That’s in Rhino 9… can someone please take a look?

---

<div class="post-metadata">

**Author:** ![Trav](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/trav/32/681734_2.png) [@Trav](https://discourse.mcneel.com/u/Trav)\
**Post date:** [March 1, 2025, 1:52pm UTC](https://discourse.mcneel.com/t/find-ngons-in-sub-d-surface/189840/11 "2025-03-01T13:52:47Z")

</div>

hmm this sounds like something Ehsan @eirannejad is likely working on with the script editor for v9.

---

<div class="post-metadata">

**Author:** ![martinsiegrist](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/martinsiegrist/32/498369_2.png) [@martinsiegrist](https://discourse.mcneel.com/u/martinsiegrist)\
**Post date:** [March 1, 2025, 2:34pm UTC](https://discourse.mcneel.com/t/find-ngons-in-sub-d-surface/189840/12 "2025-03-01T14:34:26Z")

</div>

Thanks for the information. Hopefully it’ll woork again soon.

---

<div class="post-metadata">

**Author:** ![eirannejad](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/eirannejad/32/477962_2.png) [@eirannejad](https://discourse.mcneel.com/u/eirannejad)\
**Post date:** [March 3, 2025, 9:07pm UTC](https://discourse.mcneel.com/t/find-ngons-in-sub-d-surface/189840/13 "2025-03-03T21:07:45Z")

</div>

> [@martinsiegrist](#):
>
> `System.Drawing.Primitives`

@martinsiegrist Try adding this

```csharp
// #! csharp Trav
#r "System.Drawing.Primitives.dll"

```

or this to the top of the script

```csharp
// #! csharp Trav
#r "nuget: System.Drawing.Primitives, 4.3.0"

```

---

<div class="post-metadata">

**Author:** ![martinsiegrist](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/martinsiegrist/32/498369_2.png) [@martinsiegrist](https://discourse.mcneel.com/u/martinsiegrist)\
**Post date:** [March 3, 2025, 9:17pm UTC](https://discourse.mcneel.com/t/find-ngons-in-sub-d-surface/189840/14 "2025-03-03T21:17:02Z")

</div>

Doesn’t seem to help in a button. Does it work on your end?

---

<div class="post-metadata">

**Author:** ![eirannejad](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/eirannejad/32/477962_2.png) [@eirannejad](https://discourse.mcneel.com/u/eirannejad)\
**Post date:** [March 3, 2025, 9:27pm UTC](https://discourse.mcneel.com/t/find-ngons-in-sub-d-surface/189840/15 "2025-03-03T21:27:45Z")

</div>

Nope. Actually neither does help from macro 😕 Let me see what is wrong…

---

<div class="post-metadata">

**Author:** ![martinsiegrist](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/martinsiegrist/32/498369_2.png) [@martinsiegrist](https://discourse.mcneel.com/u/martinsiegrist)\
**Post date:** [March 3, 2025, 9:29pm UTC](https://discourse.mcneel.com/t/find-ngons-in-sub-d-surface/189840/16 "2025-03-03T21:29:29Z")

</div>

Ok good, neither helps here either. 🙂

---

<div class="post-metadata">

**Author:** ![eirannejad](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/eirannejad/32/477962_2.png) [@eirannejad](https://discourse.mcneel.com/u/eirannejad)\
**Post date:** [March 3, 2025, 9:31pm UTC](https://discourse.mcneel.com/t/find-ngons-in-sub-d-surface/189840/17 "2025-03-03T21:31:41Z")

</div>

Okay found the bug. Add these lines

```csharp
#r "RhinoCodePlugin.rhp"
#r "System.Drawing.Primitives.dll"

```

I will put a fix for this for the next 8.x

---

<div class="post-metadata">

**Author:** ![martinsiegrist](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/martinsiegrist/32/498369_2.png) [@martinsiegrist](https://discourse.mcneel.com/u/martinsiegrist)\
**Post date:** [March 3, 2025, 9:38pm UTC](https://discourse.mcneel.com/t/find-ngons-in-sub-d-surface/189840/18 "2025-03-03T21:38:10Z")

</div>

> [@eirannejad](#):
>
> next 8.x

This problem is in Rhino 9 WIP

And unfortunately I could not get a button to work yet…

---

<div class="post-metadata">

**Author:** ![eirannejad](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/eirannejad/32/477962_2.png) [@eirannejad](https://discourse.mcneel.com/u/eirannejad)\
**Post date:** [March 3, 2025, 9:44pm UTC](https://discourse.mcneel.com/t/find-ngons-in-sub-d-surface/189840/19 "2025-03-03T21:44:46Z")

</div>

8.x has the same problem so it will be fixed in both. What’s the error you are seeing now?

For reference:  
[RH-86357](https://mcneel.myjetbrains.com/youtrack/issue/RH-86357) ScriptEditor command required ref to RhinoCodePlugin

---

<div class="post-metadata">

**Author:** ![martinsiegrist](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/martinsiegrist/32/498369_2.png) [@martinsiegrist](https://discourse.mcneel.com/u/martinsiegrist)\
**Post date:** [March 3, 2025, 9:49pm UTC](https://discourse.mcneel.com/t/find-ngons-in-sub-d-surface/189840/20 "2025-03-03T21:49:43Z")

</div>

It still works in script editor but fails in a button.

> Command: -ScriptEditor  
> Select Option ( Edit Run Open ): Run  
> Path of script to run ( Browse ): “C:\Users\martinsiegrist\AppData\Roaming\McNeel\Rhinoceros\8.0\scripts\MarkNgons.cs”  
> Compile Error  
> Assuming assembly reference ‘System.Drawing.Primitives, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ used by ‘RhinoCommon’ matches identity ‘System.Drawing.Primitives, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ of ‘System.Drawing.Primitives’, you may need to supply runtime policy (Warning CS1701) file:///:[1:1]  
> Assuming assembly reference ‘System.Drawing.Primitives, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ used by ‘Rhino.UI’ matches identity ‘System.Drawing.Primitives, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ of ‘System.Drawing.Primitives’, you may need to supply runtime policy (Warning CS1701) file:///:[1:1]

[Next page](https://discourse.mcneel.com/t/find-ngons-in-sub-d-surface/189840.md?page=2)
