Jump to content
Developer Wiki and Function Reference Links ×

Inserting a series of symbols


Recommended Posts

Hello,

 

I'm trying to create a script for building kitchen cabinetry using pre-built "sections" as symbols. I'm trying to prompt the user to enter the number of sections and then select the section from a drop-down list using the popup dialog. I'm not sure how to use the series node to make this work for me though.

 

For example, if the user enters "3" when prompted to enter number of sections, they should be able to select the 3 different sections from a list (popup dialog)

 

Appreciate your help. Thank You

 

 

Cabinetry Tool.vwx

Link to comment

I tried editing the script to get the node to accept a list and it kinda works the way I'd like it to work however, the first item in the List of choices get's exploded into a list of letter.

 

Below if the code for the node: 

 


#Created April 2017
@Marionette.NodeDefinition
class Params(metaclass = Marionette.OrderedClass):
#APPEARANCE
    #Name
    this = Marionette.Node( "Selection Dialog" )
    this.SetDescription( 'String Dialog, displays a dialog box which '
                        + 'requests the user to enter a string value.' )

    #Input Ports
    dListItems = Marionette.PortIn ( [], 'Choices')
    dListItems.SetDescription('Default value for input field')
    
    int = Marionette.PortIn(0, 'iDefault')
    int.SetDescription('Default value for input field')

    #OIP Controls
    Title = Marionette.OIPControl( 'Dialog Title', Marionette.WidgetType.Text, 'Dialog')
    Title.SetDescription('The name of the popup dialog -- it should advise the user as to the choice.')
    OK_s = Marionette.OIPControl( 'OK string', Marionette.WidgetType.Text, 'OK')
    OK_s.SetDescription('Localized label for the OK button.')
    Cancel_s = Marionette.OIPControl( 'Cancel string', Marionette.WidgetType.Text, 'Cancel')
    Cancel_s.SetDescription('Localized label for the Cancel button.')

    #Output Ports
    s_choice = Marionette.PortOut('sChoice')
    s_choice.SetDescription( "The string of the chosen item. If the dialog was canceled, this will be None." )
        
#BEHAVIOR
    
    #this.SetListAbsorb()
    
def RunNode(self):
    #inputs
    dlogName = self.Params.Title.value
    dlogOK = self.Params.OK_s.value
    dlogCancel = self.Params.Cancel_s.value
    dlogList = self.Params.dListItems.value
    
    global result_i
    global result_s
    dialog = 0
    debug = False
    
    #script
    
    def CreateDialog():
        dlogID = vs.CreateLayout(dlogName, False, dlogOK, dlogCancel)
        vs.CreatePullDownMenu(dlogID, 4, 24)
        vs.SetFirstLayoutItem(dlogID, 4)
        return dlogID
    
    def Dialog_handler(item, data):
        global result_i
        global result_s
        if (item == 12255): #AKA SetupDialogC
            for x in range (0, len(dlogList)):
                vs.AddChoice(dialog, 4, dlogList[x], x )
        elif (item == 1):
            (result_i, result_s) = vs.GetSelectedChoiceInfo(dialog, 4, 0)
            if debug:
                vs.AlrtDialog("result_s is ", result_s)
                vs.AlrtDialog("result_i is ", result_i)

        
    dialog = CreateDialog()
    dlog_result = False
    if vs.RunLayoutDialog(dialog, Dialog_handler) == 1:
        dlog_result = True
    elif vs.RunLayoutDialog(dialog, Dialog_handler) != 1:
        result_s = None
        result_i = None

    #outputs
    self.Params.s_choice.value = result_s


    
    

Cabinetry Tool v2.vwx

Link to comment

Hi @DomC

 

Thank You for your response. I did include the Listabsorb() into the code however, it asks the user to input "n" number of items but returns only one item in the list, when it should return "n" number of items and ask the user to select the item from the list "n" number of times.

 

For example, when running the script, the user is prompted "Enter the number of units". If the user enters 4, then the dropdown popup dialog should run 4 times so the user can select 4 of the 3 currently available options from the menu and return a list of all 4 items.

 

However, currently, it only prompts the user once and return just one item.

 

Thank You

Link to comment

The Popup list you generate delivers 3 string variables into the network. But for a popup, you need those 3 strings nested into a list as Example ['choice1', 'choice2', 'choice3']
If you run the node without list absorbing, the input with the choice would deliver 'choice1' the first time the node runs, 'choice2' the second time etc. that's how the Marionette Data-Flow works. The node repeats as many times as one input delivers values.

"list absorb", is merging all inputs into a sequence and the node just run once. So the popup there will work. But because the node run just one, your dialog run just once. you could loop through the number of dialog you want to have with the integer input you have in the node itself. Or just leave the node how it is and  merge the popup into one list. I would recommend this:


image.thumb.png.9cb35df22ff5922b51d8a22bfd20a42d.png

  • Like 2
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...