Notifications
Clear all

[Closed] Script Very Slow, How can I speed it up?

Script Attatched.

If anyone is willing to take a look at it and maybe optimize it a bit, I’ve tried
disabesceneredraw()
and
undo off ()
but its still very slow when using the “Set Height Segments From Spline To Cylinder” Button

What the script is for is to recreate a viewport renderable spline using a cylinder and path deform and edit poly modifiers.

It’s still a work in progress, “Weld Ends” button does nothing yet.

So I’m not sure what to do in order to speed up the “Set Height Segments From Spline To Cylinder”. Splines being used normally has over 400 segments.

Thanks Again CG Society.

8 Replies
1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

why do you want to recreate anything what is already built-in? just for a practicing purpose or anything else?

This is the function giving me problems for those of you who aren’t at at place they can download the zip and unzip it.


fn setsegmentspreset = 
	(
		undo off
		(
			for xx in selection where superclassof xx == Shape do
			(
				spind = xx.numSplines
				numbsegments = numKnots xx spind
				global numbsegs22 = numbsegments - 2
			)
			for ppp in selection where superclassof ppp == GeometryClass do
			(
				select ppp
				modPanel.setCurrentObject ppp.modifiers[#Edit_Poly]
				subobjectLevel = 2
				ppp.modifiers[#Edit_Poly].SetSelection #Edge #{}
				ppp.modifiers[#Edit_Poly].Select #Edge #{2, 4, 6, 9}
			)
			for i in selection where superclassof i == GeometryClass do
			(
				for x = 1 to  numbsegs22 do
				(
					local obj = modPanel.getCurrentObject()
					-- edit poly collapsed object
					if classOf obj == editable_poly or classOf obj == edit_poly then 
					(
						global customConnect_timeStamp
						global customConnect_numSegs
						if customConnect_timeStamp == undefined then 
						(
							customConnect_timeStamp = timeStamp()
							customConnect_numSegs = 1
							obj.connectEdgeSegments = customConnect_numSegs
							obj.buttonOp #connectEdges
						)
						else
						(
							local t = timeStamp() - customConnect_timeStamp
							customConnect_timeStamp += t
							customConnect_numSegs += 1
							obj.connectEdgeSegments = customConnect_numSegs
							obj.buttonOp #connectEdges
						)
					)
				)
			)
		)
	)
(
	rollout splinetosylinder "Spline Vertices to Cylinder Edge Loops"
	(
		button setheightsegments "Set Height Segments from Spline Vertices to Cylinder Edge Loops" pos: [5,5]
		on setheightsegments pressed do
		(
			disablesceneredraw()
			setsegmentspreset()
			enablesceneredraw()
		)
	)
	createDialog splinetosylinder 335 35
)

requires a spline to be selected and a specific cylinder (4 sides, 1 height segment, 1 cap segment, and an edit poly modifier applied to it)

Ok, mmmm… I just looked at what I pasted and its missing some thing i think, probably my problem. :shrug:

Because of the misdiagnoses of issues in this thread. I believe YujiKytori needs to identify the real break in his workflow and not try to over come it through scripting here and there. Without knowing the actual cause you may not be able to do what you really want.

-Eric

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

i see… the next question probably will be about how to make a scripted loft.

Ok well the real issue I guess was in the game engine, recently the importer was updated and resulted in a bug. I thought it was my files but it happens to old files I know used to work fine.

Still would be good to know how to get this script to work and work faster, I dont think that button works properly at all I’m not sure what I did wrong here.

So now its for learning purposes. Learning how to get this part to work could help me when developing other scripts that work with inserting edge loops. Like a reverse subdivision for lod creation.

this is a common delusion that a reverse subdivision can help to make LODs.

I usually model the lowest LOD first and do higher LOD’s on top of it via modifiers, but some of the people I work with dont go by my workflow, but in any case I know for a fact that a reverse subdivision can be used for lower LODs, as long as UVs are maintained.

Similar to this:
http://www.mariussilaghi.com/subdivision.htm
which seems to work only in some cases. Sometimes it wont find a subdivision reversal, even if its very high poly count.