Hello! I recently started developing a simple .net plugin for visual components. The plugin gets information from a database, then passes this information to visual components by writing it to the output. This works, but it doesn’t feel like the best solution. Is it possible to somehow call a python function from a .net plugin? If so, how do i do this? Is there some documentation i’m missing?
In a Python script, you can use vcApplication.findCommand(“netCommand”) to get a handle for the netCommand, which can be used to call a .NET command registered with the VC product.
Here is a tutorial for how to do that.
Thanks for the quick reply! But it really doesn’t answer my question. I know that i can use findCommand to get a handle for a command declared in my .Net plugin, but i want to get a handle to a python function declared in one of my models. Is this even possible?
Ah, sorry. I misread. No, you cannot get a handle for a function in a script. You can, however, make the function a Python command can call it in .NET or bind the function to a component property’s OnChanged event, so whenever you change the value of the property you know that function will be called.
Yeah, using a components property seems to be the best solution for me.
Thanks for the help, really appreciate it.
No problem, and the Add-ons course has a lesson that shows how to do that. Another thread that might interest you
One more question! How do you set the value of a string property from the plugin?
I can obtain a reference to the IProperty in my component, but how do you dynamically set a value on said property? I’ve tried createAndSetNewValue, but I get the exception “System.NotSupportedException: ‘Specified method is not supported.’”
If you are working with .NET language and .NET API, an IProperty or IProperty<T> object has a Value property, which is a getter and setter. So use that to set the value of a component property.
createAndSetNewValue… VC .NET API uses Pascal case for its naming convention, so it’s CreateAndSetNewValue.
Hi! Sorry for being unclear, I meant CreateAndSetNewValue. Forgot to capitalize create.
I’ve tried to set the Value of my IProperty with a string value, but i got an access violation exception.
I do not know what you are doing then. If I want to set the value of the Name property, for example, I could do this using both IProperty and IProperty<T>.
public void ChangeName()
if (app.World.Components.Count > 0)
ISimComponent _comp = app.World.Components;
_comp.Name = "Example";
IProperty _prop = _comp.GetProperty("Name");
_prop.Value = "Another Example";
IProperty<string> _propT = (IProperty<string>)_comp.GetProperty("Name");
_propT.Value = "Last Example";
Edit: If I had to guess, I would think you were not getting the property object first, and then setting the value.
Dear MY Friends，
I am a primary user of Visual Components, could you please instruct me how to connect VC with database? If possible, could you help me record a simple teaching video. Thanks a lot！
Depends on the database, but try this
I have used SQLite module with VC, but I don’t have access to those scripts atm.
The database I use is SQL Server. The webpage link you sent me is the method that Visual Components connects with SQL Server.
How to create behaviors in .NET?