Jump to content
Developer Wiki and Function Reference Links ×

Arcs to circles.


RDS Casa

Recommended Posts

Hello,

 

I have some files which are apparently full of circles on different layers and different classes... but actually the circles are made from 2 or more arcs

 

I need these to be actual circles - fully closed circles with a centre point.

 

A first search of the forums bought up this

 

 

with more brilliant contribution by @Pat Stanford  

 

Which almost does what I need, but to be honest I could not get it to work at all, maybe it needs a certain type of data? but it did not work on my arcs.

 

So I've turned to marionette. 

 

So far, I have a simple script, it works on a basic level, but raises some marionette question I can't answer. Please see attached.

 

Problems:

1.  : It applies it to all the arcs in the drawing, across all layers and across all classes, even if I restrict to show/snap only etc, even if the layers are turned off. 

 

I introduced a >get class >set class chain, and this at least keeps the new circles in the same class. But I really need to restrict which classes the script runs on. Is there an easy way to do this?  if it only applied to the active class, I could work with that, but ideally I could input  the classes which it would be applicable to in the OIP?

 

The same is kind of true to layers... It applies it to all layers, then dumps the new objects in to a group on the current layer?

 

I made a modified "set layer V2" node" which does not seem to  work... because I hacked it and I think I'm missing a step. please take a look. Ideally, just like the Set class chain of nodes, it would keep the layers as per parent object? but even if this does work, it throws everything into a group in the current layer, Can this be stopped? Alternatively, how do I restrict the the script to only the active layer, as this would be ok.

 

Can you add multiple criteria to the "Object by Crit" node? T must mean type? i.e. T=arc picks the arcs, but is there list of other selection criteria?

 

These other questions below are less important for my current task, but I'd still like to know how?

 

2.  The class >get class>set class works fine, but is there an short hand node that gets all the class attributes, and sets them all to the new object, with out going through line colour, fill colour etc opacity etc in individual nodes? to be honest this is not as important as problem 1. But I was interested in the answer.

 

3. Even when this is working, because the original file has circles made from 2 arcs, it will place two circles in the same place. Is there an easy way to delete the same geometry which lies on top of each other in the same layer and class? Again, this is a nice to have options for neatness. Problem one is the urgent one.

 

4. Finally, the file contains a number of  shapes I need as closed polylines. Currently they are all lines and more arcs.  which when I modify>compose almost joins them together. Sometimes it does, but most times they are 2 or 3 ploylines.  I suspect that this is because if I were to zoom right right right in, they might not touch... Any easy solutions or suggestions here?

 

Thanks everyone.

Rob

 

 

 

 

arcs to circles.vwx

Link to comment
4 hours ago, RDS Casa said:

Can you add multiple criteria to the "Object by Crit" node? T must mean type? i.e. T=arc picks the arcs, but is there list of other selection criteria?

 

Hi Rob,

 

I did a quick test and you can include multiple criteria in the Objs by Crit node's criteria field. I tested "(T=ARC) & (L='Design Layer-1')" to select all the arcs on Design Layer-1. If you are unsure of the different operators to use create a simple Custom Selection script by using Tools>Custom Selection with the criteria you want. If you edit the script from the Resource Manager you can just cut and paste the criteria into the node field.

 

I know you're on the path to creating your script but a quick way to convert all of the arcs to circles would be to select them and then change the sweep to 360 degrees in the OIP. All of the selected arcs will change to circles. It would likely result in some coincident circles but you could remove those using Tools>Purge and setting it so it removes coincident objects.

 

Kevin

 

Link to comment

Very helpful, thank you. The drawings are cutting patterns which have come out another piece of software, and are going to a CNC workshop. They need circles because of the way their machine software distinguishes drill holes from pockets or routs. So the circle thing is technical, not aesthetic.

 

One marionette problem I did have is "applying the script to selected objects" node???, which I know is simple but I can't find the solution. I've seen it done before but can't find the example. Hence I used the Object by Crit node to get the arcs as handles for the script.

 

I'll try hacking the script in the node next, ideally I'd like it to apply to all visible Layers only, this way I can use it with the most flexibility.

 

I should have thought of the purge command! simple

 

Thanks so much

Link to comment

mmm, bit trickier than I thought!

 

This is the code in the "get layer visibility" node

 

@Marionette.NodeDefinition
class Params(metaclass = Marionette.OrderedClass):
#APPEARANCE
    #Name
    this = Marionette.Node( "Get Layer Visibility" )
    this.SetDescription( 'Returns the visibility of the referenced layer' )

    #Input Ports
    obj = Marionette.PortIn( vs.Handle(0), 'hLayer' )
    obj.SetDescription( "The input layer object" )

    #OIP Controls

    #Output Ports
    visibility = Marionette.PortOut('iVisibility')    
    visibility.SetDescription( "The visibility index value. Normal - 0, Inivisble - 1, Grayed - 2" )

#BEHAVIOR

def RunNode(self):
    #inputs
    h = self.Params.obj.value

    #script
    vis = vs.GetLVis( h )

    #outputs
    self.Params.visibility.value = vis

 

This is the code for the "Objects by Crit" node

 

@Marionette.NodeDefinition
class Params(metaclass = Marionette.OrderedClass):
#APPEARANCE
    #Name
    this = Marionette.Node( 'Objs by Crit' )
    this.SetDescription( 'Returns a list of objects meeting the input criteria' )
    
    #Input Ports
    
    #OIP Controls
    crit = Marionette.OIPControl( 'Criteria', Marionette.WidgetType.Text, '')
    crit.SetDescription('A text string defining the criteria, entered in the OIP')
    
    #Output Ports
    obj = Marionette.PortOut('h')
    obj.SetDescription('The list of objects in the document that match the criteria')
    
#BEHAVIOR

def RunNode(self):
    #inputs
    crit_ = self.Params.crit.value
    
    #script
    out_list = []
    
    def Add_Handle(obj):
        out_list.append(obj)
            
    vs.ForEachObject(Add_Handle,crit_)
    
    wordTofind = "SEL=TRUE"
    searchInlist = crit_    
    searchInlist = searchInlist.replace(" ", "")
    if  wordTofind.lower() in searchInlist.lower():
        new_list = []
        parents_list = []
        for e in out_list:
            p = vs.GetParent(e)
            if  vs.GetType(p) == 11 and p in out_list:
                parents_list.append(p)
                pass
            else:
                new_list.append(e)
    
        for g in parents_list:
            if g in new_list:
                new_list.remove(g)
        #outputs
        self.Params.obj.value = new_list
    else:
        #outputs
        self.Params.obj.value = out_list

 

It feels like I should be able to adapt the latter to be, ONLY get objects specified in the OIP controls which are  also on the layers which are visible in the organise dialogue???

 

How do I start? via multiple marionette nodes, or adapt the code in the crit node?

 

Thanks

Link to comment

Hi Rob,

 

Here's a simple 3 node Marionette network that selects all the visible arcs and sets their sweep angles to 360, converting them to circles. I figured out the selection criteria using Custom Selection as I described above. The network could be converted into a script by right clicking on a node and choosing "Save Marionette Script as Python Script". You could also wrap it and convert it to a Marionette menu command.

 

Things don't undo properly for some reason so I would recommend saving your file before using the network. That way if you need to go back you can use Revert to Saved. @Marissa Farrell is there a known issue with Marionette networks not undoing correctly?

 

Kevin

 

5aad2c8867130_ScreenShot2018-03-17at7_52_46AM.thumb.png.e562b6ca7e5f435c8195ad73a5986ec2.png

 

Arcs to Circles.vwx

Edited by Kevin McAllister
Link to comment
  • Marionette Maven
8 hours ago, Kevin McAllister said:

 @Marissa Farrell is there a known issue with Marionette networks not undoing correctly?

 

There's not a definitive known issue with Marionette and undo, but there is a possibility that there is an issue. We haven't found a reproducible case, however if you can find one we can use it to locate the issue. 

Link to comment
  • 2 weeks later...

I downloaded the file in the first post on Mar 17th, but only now played with it. Like Kevin, I reduced the network to take advantage of the vs.SetArc() command. This has the advantage of preserving the graphic attributes of the original ARCs and their stacking order on the page. I, too, noticed UNDO was broken for my network, while it works for the original network. I believe this is due to the different ways these networks run. Rob's network runs like an object PIO, and Kevin's and my networks run like a Menu Command.

 

Rob's network uses ARCs as input and creates a group of CIRCLEs from them, then it deletes the ARCs; while Kevin's and my networks modify the original ARCs and create no output object. A typical Marionette network creates an output. When a network is rerun, the existing output object is deleted and a new object is created. UNDO works for this scenario.

 

In my network, no new object is created. The existing ARCs are modified to CIRCLEs. UNDO does not work to restore them. See attached file.

 

Marissa, I hope this gets you pointed in the right direction.

 

Raymond 

 

arcs to circles (RM).vwx

  • Like 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...