get selected spline ID

Hi,
BARIGAZY made a script to select all faces matching id selected faces.
It is very handy as you can select multiple id and get all faces with same id.

I would like to have same thing for spline segments.
When working in archviz it would be very helpfull to clean big projects from dwg plans.
Thanks.

Comments

Comment viewing options

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

Hi, thank you Miauu it

Hi,
thank you Miauu it works.
But could it be possible to select all segments ID of already selected segment ID.
For exemple if the drawing is well done ( sometimes it is true ) you can select one segment of a door, one of a bed, and one of a sink, click "select" and boom all doors, all furnitures and all bath furniture is selected !
Sometimes ID of drawings are numerous and it is not handy to write all by hand...

Cheers

miauu's picture

.

For exemple if the drawing is well done ( sometimes it is true ) you can select one segment of a door, one of a bed, and one of a sink, click "select" and boom all doors, all furnitures and all bath furniture is selected !

The objects should be selected or segments with given matIDs?

How the script to know which objects are doors, furnitures, etc?

 

 

 

titane357's picture

ah ah ! the script don't know

ah ah ! the script don't know but if drawing is well organized, each type of element has a specified ID.

miauu's picture

.

You have to explain this better. :)
All drawings are only one single spline shape with 1000+ (sub)splines?

If YES, then do you want to select several segments and the script to selec all other segments that have the same matID?

If NO - do you want to select several shapes, and in each one of this shapes to select several segments, and then the script to find the matIDs of those segments, to loop through all other splines in the scene and to select all splines which have segments with the same matID(the segments to be selected too)?

You can send me a test scene to show me how exactly the drawings looks, what do you want to select and what the script have to select.

titane357's picture

Hi, sorry I was at home and

Hi, sorry I was at home and had no files...
so : YES All drawings are only one single spline shape with 1000+ (sub)splines.
I join you a very basic file to explain.
This is a already silmplified portion of a huge hospital...
When I need to model I need to clear all data I don't need to speed up my work.
Thousands on unused vertex slow down a lot when snapping...
In the file I need for example, select all is inside the room : doors, Sanitary facilities, furnitures, and notes. And then delete.
ID are never the same. So, it is very handy to select one segment of a door, one of a toilet,... and clic a button to select all identical IDs.
When I get a land surveyor document, there is a lot of elements I need to delete, and taping its ID by hand is not the more handy.
Hope this can help. Thanks

AttachmentSize
ex.zip 394.84 KB
miauu's picture

.

OK. Try the attached script and let me know if it works properly or not.

AttachmentSize
miauuselectsplinesegmentbymatid.ms 4.41 KB
titane357's picture

Hi Miauu, As always it works

Hi Miauu,
As always it works perfectly.... :-)
It is a pleasure now to select all unwanted segments !
Too bad that max isn't multithreaded, and to delete some segments it is a little slow ( I have some big drawings )
I saw you are using bitArrays, it is like chinese for me...
Thanks a lot !!
Cheers.

miauu's picture

.

Thank you. ;)

miauu's picture

.

Test this and if it works I will post is as a script in the proper section.
In the textbox you can enter as many IDs as you want but always separate them with comma.

--******************************************************************************************************
-- Created: 		--	"3.5.2019 г. 21:00:19"
-- Last Updated:	--	"3.5.2019 г. 21:18:20"
-- Version:			1.00
--
-- Author :  Kostadin Kotev / [email protected] / http://miauumaxscript.blogspot.bg/
-- Version:  3ds max 2009 
--
-- Discription: DESCRIPTION
-- Usage: RUN IT
--
-- Wishlist:
--
--******************************************************************************************************
-- MODIFY THIS AT YOUR OWN RISK
 
(
	global rol_selSegsByMatID
	try(destroyDialog rol_selSegsByMatID)catch()
	rollout rol_selSegsByMatID "Select segments by matID"
	(
		edittext et_matID "Material ID:" text:"1,2,3,4"
		button btn_select "SELECT" width:140
 
		on btn_select pressed do
		(
			if selection.count != 0 do
			(
				splArr = for o in selection where classOf o == SplineShape or classOf o == Line collect o
				if splArr.count != 0 and et_matID.text != "" do
				(					
					matIdsBA = readValue (("#{" + et_matID.text + "}") as stringstream)
					for s in splArr do
					(
						ssCnt = numSplines s
 
						for sIdx = 1 to ssCnt do
						(
							setSegSelection s sIdx #()
							segsToSelectArr = #()
							segsCnt = numSegments s sIdx
							for seg = 1 to segsCnt do
							(
								segMatID = getMaterialID s sIdx seg
								if not (matIdsBA * #{segMatID}).isEmpty do
								(
 
									append segsToSelectArr seg
								)
							)
							setSegSelection s sIdx segsToSelectArr keep:true
						)
 
					)
				)
			)
		)
 
		function String2Bmp string =
		(
			local clipboardClass = dotNetClass "System.Windows.Forms.Clipboard"
			local ConvertClass = dotnetclass "system.convert"
			local imageclass = dotNetclass "System.Drawing.image"
			local bytearr = convertclass.FromBase64String string
			local memstream = dotnetobject "System.IO.MemoryStream" bytearr
			local DecodedImg = ImageClass.fromstream memstream
			memstream.close()
			iconBMP = DecodedImg
			iconBMP
		)
		function LoadMyLogoAsTitlebarIcon =
		(
			local logoIcon = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAIGNIUk0AAHolAACAgwAA+f8AAIDpAAB1MAAA6mAAADqYAAAXb5JfxUYAAAAJcEhZcwAACxIAAAsSAdLdfvwAAALcSURBVDhPbZJLSFRhGIa/1C6IMmmQFNownplzv8y5zIzOqGPimE5hFxfeZxQzu0AXDbtsXHWBwNpWaIt2lQWBFSS0qCholbsW7QwiiKBNRDlv//xTWtjiO9+B77zP+37/+QkA7QxXULu7mZLmVmq1K2lvtIzSjm/A0Wt/NjdEl0d62w+eGe2gyUyCTvXHaawnSRNDTVy7AuhwfdTt+Kg1XBFIWNVLmqZj/ryGc90yVN1CZ3vjx9PDLWpS3UJH+pI0nv0L0MaEaa+cYnr1M0OVIKkWNN0AXsQxe0KCIkvwCxI818bgvsTL8eFWmhpLrgLq9Korri4si4oJVTNg6Covy5RhGQrrOusqQqIEQVSQqI/mjvY1T68AhJCc0wwLuqbwmuwKAfdcDkl4MvAmjr1NEgNpMA0NghCEFXZzKwBRFHP54WhawudbNpbuePg+5+DVBR3vZlxgIYrFqwY+zNjoSckcbNvhVYAkhnIWI4/36czZRiNzzX/07kYYl7MSd812qsC8h96UxFOy81gLOLSHxX3ooi4scsBb5jrVL3PAGJt9u2uju7Wwpuc6awEne1mChRganALgy/0oprMiB5wdsXiCgV1yAeD8B3B8P0vwOIJUfWGFL7ct3DymcsDxLgV45GEo/SfBXyvIssQPcWKQ/XsGaP8NeP+gHtdGFA6YHLOBJxFkdv1nhUBtMOc4Nhflh/lusuKdifPp8j1fYWaksJtpOLFVgFNbOltd44fCLpFpsdiHJbZvhAPa6tj763pkUiJ000JIjzATGW12xfMVQIuygbZv2bhJ2uFbDAYFXDrh4dP1MAMoSCU14GkMnc0Wu+Immqyqz/2xdXXDsYKWPxqkUvJvKyM3UEJ6TUlc8ld+9QsqNNNmrg4ExUHEqPlxwF1/6nAD0WgjUU+0+F9ATVU5WYFSigY3kreDKOIvuaiGqpdNNYTdbtncSJzoYIIoGy+mTLyIAYqYFvQLPey9qVeXvysAAAAASUVORK5CYII="
			d = (windows.getChildHWND 0 rol_selSegsByMatID.title)[1]
			WM_SETICON = 0x0080
			ICON_SMALL = 0
			bm = dotnetobject "System.Drawing.Bitmap" (String2Bmp logoIcon)			
			ptr = bm.GetHicon()
			icon = (dotnetclass "System.Drawing.Icon").FromHandle (dotnetobject "IntPtr" ptr)			
			windows.SendMessage d WM_SETICON ICON_SMALL icon.handle
		)
 
		on rol_selSegsByMatID open do
		(
			LoadMyLogoAsTitlebarIcon()
		)		
	)
	createdialog rol_selSegsByMatID 
)

Comment viewing options

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