Maxscript dotnet

Hi Guys,

I'm working on a script which uses a dotnet form for the UI. One of the elements is a ListView. When trying to get it to select one of the items I get an error. I'm basing a lot of it around:
http://scriptattack.com/snippets/snippets.html

Although I have to call functions like this:

fn Shot_lb_Get Shot_lb evnt =
(
hit=(Shot_lb.HitTest (dotNetObject "System.Drawing.Point" arg.x arg.y))
row=hit.item.Index
)
dotnet.addEventHandler Shot_lb "MouseUp" Shot_lb_Get

Does anyone have an idea why it fails?

John

Comments

Comment viewing options

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

Works

That works great for me, for now. I might want the index number at some point but not for now. Thank-you.

John

pixamoon's picture

index

Sure :) To get index of first selected item:

lv_objects.SelectedItems.item[0].index

One important thing: dotNet arrays index starts from 0 (not like maxscript from 1)

Best,
Pixamoon

johncrawshaw's picture

You little beauty! Perfect.

While you seem to be a bit of a dotnet genius. Don't suppose you know how to fix the padding on a dotnet webpage? (its a test image)

webbrowser_rollout = dotNetObject "System.Windows.Forms.WebBrowser"
webbrowser_rollout.Url = dotNetObject "System.Uri" "http://assets3.parliament.uk/iv/main-large//ImageVault/Images/id_7382/scope_0/ImageVaultHandler.aspx.jpg"
webbrowser_rollout.Margin = dotNetObject "System.Windows.Forms.Padding" 0 0 0 0
webbrowser_rollout.ScrollBarsEnabled = false
webbrowser_rollout.Width = 242
webbrowser_rollout.Height = 184
webbrowser_rollout.left = 200
webbrowser_rollout.top = 30
dn_form_Tasks.controls.add webbrowser_rollout

John

pixamoon's picture

`

no no, I just had the same problems recently for my scripts... :p

I've never used dotnet webpage, but I'll take a look. It's nice to learn new things :)

Best,
Pixamoon

pixamoon's picture

`

but do you need browser or you just want to add image / logo from the web to your script ?

johncrawshaw's picture

Image

An picture box would do. But the url I have is very long for the image I want to download. The web browser doesn't have a problem with the length. Its just really annoying the padding thing!!

pixamoon's picture

`

yes, I was thinking about download image and than use it.
Did you try download with dotnet ?

I tried a bit your browser code. Still no success to change padding but I tried
webbrowser_rollout.left = -15
webbrowser_rollout.top = -10

to move image left and up,
this is only temporary solution :(

pixamoon's picture

download file

did you try this way to download:

url = "http://assets3.parliament.uk/iv/main-large//ImageVault/Images/id_7382/scope_0/ImageVaultHandler.aspx.jpg"
newFile = (getDir #temp) + "//" + "00_test.jpg"
 
fn DownloadFile url newFile = (
	wc=dotNetClass "System.Net.WebClient"
	sr=dotNetClass "System.IO.StreamReader"
	wcobj=(dotNetObject wc)
	stm=wcobj.DownloadFile url newFile
)
 
DownloadFile url newFile
shellLaunch newFile ""

It works here with your test image.

johncrawshaw's picture

Wow

That's perfect!! I can just download all the thumbnails to the local drive and then reference them from there. Thanks-you so much. My UI will look loads better now. And quicker!

John

pixamoon's picture

`

nice :)

but you can also add your thumbnails to .mzp file and they will be copied during installation

take a look on:
http://www.scriptspot.com/3ds-max/scripts/drop-and-relink

mzp.run file makes this job.

mzp format is just a zip file with different extension.

Comment viewing options

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