ScriptSpot

Forum topic · General Scripting

Maxscript dotnet

By johncrawshaw · 2015-03-30

Description

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:

Does anyone have an idea why it fails?

John

Comments (12)

Works

johncrawshaw · 2015-03-31

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

John

index

pixamoon · 2015-03-31

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

You little beauty! Perfect.

johncrawshaw · 2015-04-01

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)

John

`

pixamoon · 2015-04-01

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 · 2015-04-01

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

Image

johncrawshaw · 2015-04-01

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 · 2015-04-01

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 :(

download file

pixamoon · 2015-04-01

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.

Wow

johncrawshaw · 2015-04-01

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 · 2015-04-01

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.

select in ListView

pixamoon · 2015-03-30

Hi,
Do you want to select by script one item/line of listView or get selected line/lines?

Like in http://www.scriptspot.com/3ds-max/scripts/bitmap-tracking-resizing
or http://www.scriptspot.com/3ds-max/scripts/library-track-relink

to get selecttion count:

lv_objects.selecteditems.count

to get first selected item:

lv_objects.SelectedItems.item[0].subitems.item[0].text

to select 1st on the list:

lv_objects.Items.item[0].selected = true

where lv_objects is dotnet ListView

Hope it helps
Pixamoon