ScriptSpot home

Forum topic · General Scripting

COPY VERTEX ID IN CLIPBOARD.

By Nikolay Litvinov · 2013-01-20

Downloads
Description

How to make for copy vertex-ID of several objects with Edit_poly modifer (by Tab forexample)?

copy vertex id

Comments (23)
Nikolay Litvinov

Thank you very much for everything

Ok Thank you very much for everything. I hope I'm not too stop you. You surprised me with your compassion. Really nice :)

Nikolay Litvinov

Error :) --Unknown system exception

As so

Reply to Nikolay Litvinov
Branko Živković

Now we talking :)

Now i tested in max.

;)


macroScript Copy_VertsID ButtonText:"CopyVertsID" Category:"bga_Tools" Tooltip:"Copy V-ID To Clipboard"
(
local Clipboard = dotNetClass "Clipboard"
local obj = selection[1]
if obj != undefined and isKindOf obj Editable_Poly or isKindOf obj Editable_Mesh do
(
local vIDArr = obj.selectedverts as bitarray
local clipStr = ""
if vIDArr.numberset == 0 then messageBox "Select Some Verts First!" title:"Warning" beep:off else
(
for i in vIDArr do append clipStr (i as string + " ")
Clipboard.Clear()
Clipboard.SetDataObject clipStr true
)
)
)

Reply to Nikolay Litvinov
Panayot Karabakalov

Hi Nikolay

I think that this come from the line:

on btnCopy pressed do

Maybe coincident copy/paste mistake. When Branko remove the rollout he forget to remove and the button event. So delete that line, or try with my edited code:

MacroScript mcr_VertIDToClipboard 
category:"bga_Tools" 
buttonText:"CopyVertsID" 
toolTip:"Verts ID To Clipboard"
(
	local obj = selection[1]
	if obj != undefined and \
	(isKindOf obj Editable_Poly or isKindOf obj Editable_Mesh) do
	(
		local vIDArr = obj.selectedVerts as bitArray
		if vIDArr.isEmpty then
			messageBox "Select Some Verts First!" title:"Warning" beep:off
		else
		(
			local clipStr = ""
			for i in vIDArr do append clipStr (i as string + " ")
			setclipboardText clipStr
		)
	)	
)

@Branko - wow, we posted at the same time! :)

Reply to Panayot Karabakalov
Branko Živković

Hi Panayot,
yes, rollout lines of code i forget to remove.
By the way, nice mxs version.
Cheers!

Nikolay Litvinov

Ещё :)

Ещё ошибки пошли :)
Why is that?

Attachments
Reply to Nikolay Litvinov
Branko Živković

Sorry :)

 macroscript Copy_VertsID

I not have max in front of me.I use the cell phone.Lol
Теперь он должен работать :)

Nikolay Litvinov

Here such error issue

I'm sorry for molestation
with drag & drop of macroscripr

Attachments
Nikolay Litvinov

Branko, аnd without rollout make this script?

Schutcut only.

Nikolay Litvinov

! You golden man, thank you very much!

works thanks!

Branko Živković

edit

About data output

--if you using this line
i as string + " "
--then the output (after paste) will look like this
result > 10 12 54 668 44 454 454 ...
--or if you change to
i as string + "\n"
--then the output will look
result >
10
12
54
668
...

Nikolay Litvinov

Branko friend, help me.
And the rollout inappropriately
let it be only shotcut

Reply to Nikolay Litvinov
Branko Živković

Select en EditPoly or EditMesh object, pick some verts and press the button. Then just past data in any text editor

try(destroyDialog ::test)catch()
rollout test "Copy V-ID To Clipboard"
(
fn filterGeom geo = isKindOf geo Editable_Poly or isKindOf geo Editable_Mesh

button btnCopy "Copy Vertex ID" width:146

local Clipboard = dotNetClass "Clipboard"
--local sysStr = dotNetClass "System.String"
on btnCopy pressed do
(
local obj = selection[1]
if obj != undefined and filterGeom obj do
(
local vIDArr = obj.selectedverts as bitarray
local clipStr = ""
if vIDArr.numberset == 0 then messageBox "Select Some Verts First!" title:"Warning" beep:off else
(
for i in vIDArr do append clipStr (i as string + " ")
Clipboard.Clear()
Clipboard.SetDataObject clipStr true
)
)
)
)
createDialog test 150 30

Nikolay Litvinov

That's how it looked (I created a gif, look)

No text display is certainly not required (such as "Copy Vertex ID to Clipboard").
And showing vertex id is also not necessary - it is, I have, as seen.
Operation is simply copy-paste Vertex ID
Many thanks for your reply

Attachments
Reply to Nikolay Litvinov
Branko Živković

try this


rollout test "Copy V-ID To Clipboard"
(
	fn filterGeom geo = isKindOf geo Editable_Poly or isKindOf geo Editable_Mesh
	
	button btnCopy "Copy Vertex ID" width:146
 
	local Clipboard = dotNetClass "Clipboard"
	on btnCopy pressed do 
	(
		local selSet = getCurrentSelection()
		clearSelection()
		if selSet.count != 0 do
		(
			if getCommandPanelTaskMode() != #create do setCommandPanelTaskMode mode:#create
			with redraw off 
			(
				for obj in selSet where filterGeom geo do
				(
					clipStr = ""
					vIDArr = obj.selectedverts as bitarray
					if vIDArr.numset != 0 do 
					(
						for i in vIDArr do append clipStr (i as string + " ")
						Clipboard.Clear()
						Clipboard.SetText clipStr
					)
				)
			)
		)
		--select selSet
		free selSet
	)
)
createDialog test 150 30 fgcolor:yellow

Similal script you can find here
http://www.scriptspot.com/forums/3ds-max/scripts-wanted/object-name-to-c…

Reply to Branko Živković
Nikolay Litvinov

It's not work

Does not work, please, help me please
I think the remnants of my code muddled

Branko Živković

start

I will start like this and you need to tell me what's next :)

fn filterGeom geo = isKindOf geo Editable_Poly or isKindOf geo Editable_Mesh
selSet = getCurrentSelection()
clearSelection()
if selSet.count != 0 do
(
if getCommandPanelTaskMode() != #create do setCommandPanelTaskMode mode:#create
with redraw off
(
for obj in selSet where filterGeom geo do
(
--???
)
)
)
select selSet
free selSet

Branko Živković

Please explain better what you exactly want to achive?