Plugin Cafe Homepage
Forum Home Forum Home > Plugin Cafe > PYTHON Development
  New Posts New Posts
  FAQ FAQ  Forum Search

Outline selection?

Author
Message
  Topic Search Topic Search
fnoller View Drop Down
Member
Member


Joined: 2018 Aug 11
Online Status: Offline
Posts: 5
Direct Link To This Post Topic: Outline selection?
    Posted: 2018 Aug 30 at 1:12pm
Hi all,

How can I select the outline edges of selected polygons in python, just like the command "Outline Selection"?

Best regards

Fnoller


Edited by fnoller - 2018 Aug 30 at 8:46pm
Back to Top
MaximeA View Drop Down
Forum Moderator
Forum Moderator

Forum Moderator

Joined: 2018 Jan 04
Location: France - Nantes
Online Status: Offline
Posts: 119
Direct Link To This Post Posted: 2018 Aug 31 at 5:31am
Hi fnoller,

I'm afraid, as mentioned here there is no direct way to use our internal command for select outline.
You get a basic implementation of the comment from Donovan by Cesar Vonc [URL=https://code.vonc.fr/?a=100#f-SelectionneAretesContour] which might help you.

If you have any question please let me know.
Cheers,
Maxime!
MAXON
SDK Specialist
Back to Top
fnoller View Drop Down
Member
Member


Joined: 2018 Aug 11
Online Status: Offline
Posts: 5
Direct Link To This Post Posted: 2018 Aug 31 at 9:50pm
Hi MaximeA

Thank you very much.

Fnoller
Back to Top
fnoller View Drop Down
Member
Member


Joined: 2018 Aug 11
Online Status: Offline
Posts: 5
Direct Link To This Post Posted: 2018 Aug 31 at 10:13pm
I got it working :) Here is the code if anyone else need a script for converting polygon selection to edge selection.

def convert_polygon_selection_to_edge_selection(obj):
    n = c4d.utils.Neighbor()
    n.Init(obj)

    selected = obj.GetPolygonS()

    polys = obj.GetAllPolygons()
    bs = c4d.BaseSelect()
    for i, pol in enumerate(polys):
        if selected.IsSelected(i):
            pa = pol.a
            pb = pol.b
            pc = pol.c
            pd = pol.d

            nab = n.GetNeighbor(pa, pb, i)
            nbc = n.GetNeighbor(pb, pc, i)
            ncd = n.GetNeighbor(pc, pd, i)
            nda = n.GetNeighbor(pd, pa, i)

            cotes = n.GetPolyInfo(i)["edge"]
            # Bottom edge
            if not selected.IsSelected(nab) or nab == -1:
                bs.Select(cotes[0])
            # Left edge
            if not selected.IsSelected(nbc) or nbc == -1:
                bs.Select(cotes[1])
            # Top edge
            if not selected.IsSelected(ncd) or ncd == -1:
                if pc != pd: bs.Select(cotes[2])
            # Right edge
            if not selected.IsSelected(nda) or nda == -1:
                bs.Select(cotes[3])

    obj.SetSelectedEdges(n, bs, c4d.EDGESELECTIONTYPE_SELECTION)


Edited by fnoller - 2018 Aug 31 at 10:18pm
Back to Top

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.61 [Free Express Edition]
Copyright ©2001-2009 Web Wiz

This page was generated in 0.094 seconds.