Change patch name with setup

benoitlahoz's picture

Hello !

I want to program something I saw in NI plugins for example. Here is the situation :

  • I hace a custom patch with a setup panel ;
  • In this setup I can choose, let's say, if I want to display a circle or a box, and then what kind of inputs the patch has ;
  • I would like the name of the patch to change to display what I'm working with (Box or Circle).

I don't know where to begin. I guess there is a "key value" thing to tinker, isn't it ?

Thanks a lot !

Ben

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

benoitlahoz's picture
Re: Change patch name with setup

In fact, I manage to change the title of the patch, accessing to the class method + (void) attributes.

But, if I define my NSString* name in the global area, all the patches change their names. How can I access the class method and pass it an instance variable ? Hummmm... Noobs question ?

usefuldesign.au's picture
Re: Change patch name with setup

Just wanted to compliment you on you avatar, wish I was Cocoa savvy but I'm not.

benoitlahoz's picture
Re: Change patch name with setup

:-) Thank you !

dust's picture
Re: Change patch name with setup

hmmm,. I do not think I'm understanding your question correctly. your trying to change the name of a patch once it is loaded ? so in your app there are two choices circle and square. both circle and square are patches ? when a user loads circle patch the name says circle and you want user to be able to rename to my circle ? and or vice versa for the square patch.

changing a name via the file systems seems like it would mess up your patch loading. you could do this with a string ivar and re load the patch with the new name after changing the name which in turn should change the name in your set up window. another way could be to make a document style app that way the user can save the whole document as my circle or something. also you could store the patches file name url into a dictionary with a user defined key. then display the key as the file name. that might be less messy.

just a shot on the dark here as I guess I don't really understand what your asking. when you say parch are you referring to a plugin or a qc file loaded with importer ?

benoitlahoz's picture
Re: Change patch name with setup

Thanks Dust. I might explain myself better.

I'm developping a plugin (custom patch) to be used in the QC editor.

Through my setup panel the user is able to change the type of object to be used. For example, I have several common inputs for both circles and squares, but I change these inputs via the setup panel :

  • Square : Width, Height
  • Circle : Radius

I would like to change dynamically the displayed name (after the choice has been made) of the custom patch so the user can visualize easily if he's using a circle or a square.

I manage to change it dynamically with

[self setAttributes:[NSDictionary dictionaryWithObjectsAndKeys:@"BOX", QCPlugInAttributeNameKey, kQCPlugIn_Description, QCPlugInAttributeDescriptionKey, nil]];

but it is changing the attribute of ALL the patches in the editor, circles, boxes, or not...

What I really would like to do is to "emulate" (sorry for my English) the way we change the name of a patch manually. Or... any other solution would be highly appreciated ! :-)

dust's picture
Re: Change patch name with setup

ok i got it..... you want to change the name of a patch in the editor dynamically. that sounds like a job for the skany sdk maybe ? i really have no idea how you would go about that other than setting your attributes but like you said that changes all the patches names.

why not make a dynamic input port with the name "inputBox" or "inputCircle". kind of like how qcOSC works. i think there is source for that project ?

gtoledo3's picture
Re: Change patch name with setup

What patch actually changes it's name in this way? Never seen that before, kinda curious.

benoitlahoz's picture
Re: Change patch name with setup

Here's a capture of my patches and the setup panel. As you can see I'm finalizing my Box2D plugin. The 2 patches are the same object, but I change the inputs according to the user's choice.

@dust In fact, I already have a lot of patches to plug together to my final renderer, so I would like to avoid adding one more (which would be logical for Box2D (Shape -> Fixture -> Bodydef -> Body -> World) but too tiresome for what I want to do in QC.

I can't find anymore this plugin that was able to change its name (and even its type : provider, processor, etc.) dynamically. But I guess it was a NI patch.

bwalkin's picture
Re: Change patch name with setup

This is possible with the SkankySDK. Call [[self userInfo] setObject:@"Some Custom Name" forKey:@"name"] to change the name of the patch when the user interacts with some control in the Settings panel. It will only change the name of the patch you call it on. I do this in a few of my patches.

benoitlahoz's picture
Re: Change patch name with setup

Thanks @bwalkin...

Unfortunately I'm using the officiel API... :-/

User will have to be careful of inputs...

gtoledo3's picture
Re: Change patch name with setup

Try looking at the skankySDK sometime, especially when shuffling structures around :) Checkout datatools and gltools xcode projects and how it implements some of those tricks.

benoitlahoz's picture
Re: Change patch name with setup

Thanks for the advice @gtoledo3 !

In fact, I begun with the standard API, and it took time yet for me to understand :-/

This might be the next step. You're right : as I'm dealing with custom classes/objects, having custom inputs and outputs, then being able to tinker with deeper QC, all this would be great !!!