News:

All posts discussing pricing or where to buy TurboCAD will be deleted.

Main Menu

Need .xaml code for user imput

Started by Cad Man, March 09, 2022, 11:12:54 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Cad Man

In a Readme file it says TurboCAD's Ruby engine allows you to use WPF to create XAML-based dialog boxes for user impute in your Ruby script.  Does anybody have any sample code that I can use to create these user input dialog boxes?  I want to obtain user input for changing object attributes.

Andy H

There is a simple sample form in the ruby script folder.  in a default TC installation, it is in  Documents - TurboCAd (whateverversion) - RubyScripts

The xaml for the dialog, is RectangleWPFSample.xaml,  and the ruby script that references the xaml is TC20_ApiRectangle.rb.  Both can be opened in Notepad to view the code.  To view it in action.  In TC. Open ruby console, and in the bottom right Combobox find TC Rectangle.  The rectangle is put in TC at coordinates x = 0, y = 0

The form is pretty simple, but its a start.   I've only tried creating one form, using the free MS visual studio.  Which one can design the form and have VS output as xaml.   I never got round to writing any ruby script to use the form though.

nikkipollard

#2
There is also an example to code a windows form in Ruby.
TC20_DynamicFormCreation.rb

That is as far as I got too.
If you manage to figure out how to change object properties via Ruby, Please can you post an example - That is where i gave up with Ruby
Nikki
TC20 platinum, TC 2015 platinum
TC 2017 with lightworks
TC 2021 platinum
Windows 11 Home 22h

Cad Man

Thank you for your replies Andy and Nikki.  In the rectangle example, having trouble distinguishing the xaml code from the ruby (unless the xaml is in a separate file stored elsewhere.  At least this is a good start. 
The dynamic form example helps me to realize, I may not need to learn xaml as well, but maybe can get the job done with just ruby.
To your question about changing properties, I've been looking at the user guide for Version 18 (I have the LTE Pro version. 9 which came out in January 2017) and I seem to recall a section explaining that but haven't read it yet.  It isn't in the few sections I printed out.

Cad Man

Andy.  I went back and found the RectangleWPFSample.Xaml file.  Now I have to decide whether to try to spend time trying to create something using xaml or go the dynamic form route.  I like your idea of maybe trying to use a free version of visual basic as a possible short cut.

nikkipollard

#5
Visual studio community version is more then enough for working with the Turbocad sdk.
I don't think you need to use VB for the Xaml form - You just use visual studio create the form visually. - Basically drag the controls on to the form and Visual studio writes the code in Xaml. - You may have to do a little Xaml coding
here is a basic wpf tutorial
https://www.youtube.com/watch?v=ImH_LvRMISw
The coding of the buttons - is done via Ruby.
Nikki
TC20 platinum, TC 2015 platinum
TC 2017 with lightworks
TC 2021 platinum
Windows 11 Home 22h

Cad Man

Thank you Nikki.  I will be working on it.  I am hoping that receiving input from the buttons won't be too big of a problem since xaml and ruby are too different script languages.  Using VS does seem to make the most sense for constructing the dialog box.

nikkipollard

#7
i don't really understand how all these different languages communicate with eachother. - all I know is if you have the same require clauses as the example Ruby file has, then Ruby is able work with the Xaml file. - the same way that C# or Vb.net are able to work with those forms.

I just tested it the only thing I found is that Visual studio added a few lines of code in the beginning of the Xaml file that ruby didn't like.
I deleted that and replaced it with the code in the example xaml file. The xaml file needs to be in the ruby folder.
Nikki
TC20 platinum, TC 2015 platinum
TC 2017 with lightworks
TC 2021 platinum
Windows 11 Home 22h

Cad Man

Thanks Nikki.  Gives me a good place to start.  Now to download VS free version