View Full Version : convertToMesh!!!
Blanks 07-10-2009, 03:41 PM I'm helping somebody with a script and we are trying to convert a renderable spline to an editable mesh using convertToMesh, after some operations but it always seems to convert it before the operations are complete. Does this seem unusual or do I have to test to see if an operation is complete, somehow, before converting?? It also does the same when changing the subobject mode.
Any help would be appreciated.
Jamell
|
|
Kramsurfer
07-10-2009, 05:37 PM
"after some operations" is sorta vague... can you post some code?
Blanks
07-10-2009, 07:27 PM
sorry I didnt want to post the script as it isn't mine but anyway I was helping apunctg. I think you replied to his thread about the spline segments where he posted the script. That's the script I was referring to.
apunctg
07-10-2009, 08:10 PM
hi,
the code that works is this one
Mlength = 5
Mwidth = 0.25
modPanel.addModToSelection (Normalize_Spl ()) ui:on
$.modifiers[#Normalize_Spl].length = Mlength
macros.run "Modifier Stack" "Convert_to_Spline"
for n = 1 to (numSplines $) do
(
selsegs = #()
for i = 1 to (numSegments $ n) by 2 do
(
append selsegs i
)
subobjectLevel = 1
for k = 1 to (numKnots $ n) do
(
setKnotType $ n k #bezier
updateShape $
)
setSegSelection $ n selsegs
)
subobjectLevel = 2
splineOps.delete $
subobjectLevel = 0
$.render_renderable = true
$.render_displayRenderMesh = true
$.render_rectangular = true
$.render_length = 0.01
$.render_width = Mwidth
convertToMesh $
and with it integrated in a rollout it doesn't
rollout MarcajeStr "Dashed Lines - by apunctg"
(
spinner Mlength "Length: " range:[0.01,100,5]
spinner Mwidth "Width: " range:[0.01,100,0.15]
button create "Create Dashed Lines"
on create pressed do
(
modPanel.addModToSelection (Normalize_Spl ()) ui:on
$.modifiers[#Normalize_Spl].length = Mlength.value
macros.run "Modifier Stack" "Convert_to_Spline"
for n = 1 to (numSplines $) do
(
selsegs = #()
for i = 1 to (numSegments $ n) by 2 do
(
append selsegs i
)
subobjectLevel = 1
for k = 1 to (numKnots $ n) do
(
setKnotType $ n k #bezier
updateShape $
)
setSegSelection $ n selsegs
)
subobjectLevel = 2
splineOps.delete $
subobjectLevel = 0
$.render_renderable = true
$.render_displayRenderMesh = true
$.render_rectangular = true
$.render_length = 0.01
$.render_width = Mwidth.value
convertToMesh $
)
createDialog MarcajeStr width:200
denisT
07-12-2009, 06:55 PM
rollout MarcajeStr "Dashed Lines - by apunctg"
(spinner ui_length "Length: " range:[0.01,100,5]
spinner ui_width "Width: " range:[0.01,100,0.15]
button create "Create Dashed Lines"
fn dashSpline length:5.0 width:0.25 height:0.01 = if iskindof (spline = selection[1]) Shape do
(modPanel.addModToSelection (Normalize_Spl length:length) ui:on
convertToSplineShape spline
spline.render_renderable = true
spline.render_displayRenderMesh = true
spline.render_rectangular = true
spline.render_length = height
spline.render_width = width
for n=1 to (numSplines spline) do
(for k=1 to (numKnots spline n) do setKnotType spline n k #bezier
local segs = for i=1 to (numSegments spline n) by 2 collect i
setSegSelection spline n segs
)
updateShape spline
subobjectLevel = 2
modPanel.addModToSelection (deleteSplineModifier())
convertToMesh spline
)
on create pressed do undo "Create Dashed" on dashSpline length:ui_length.value width:ui_width.value height:0.01
)
createDialog MarcajeStr width:200
apunctg
07-12-2009, 09:47 PM
thanks for your reply Denis , now it's working perfectly !
I have another thing to ask ... where i did wrong. From what u added i figure that i needed to refer to an object instead of a simple selection "$" when working with a rollot and i needed to make a local variable - "local segs".
sorry for these questions but i am trying to understand how this work.
Thanks again !
Blanks
07-12-2009, 10:25 PM
Thanks for the reply, I didnt think of using the deleteSplineModifier. To be honest didnt even know it was there. Im still curious why the other method didnt work because it worked wasnt called in a button. Didnt make sense to me. I even tried calling 2 functions one for deleting the spline and one for converting to mesh but it didnt work. Anyway what do I know Im a beginner.
apunctg- I dont think it has anything to do with the local variable. I believe it would be local even if it wasn't declared local in the for loops scope anyway.
denisT
07-13-2009, 06:13 PM
I have another thing to ask ... where i did wrong. From what u added i figure that i needed to refer to an object instead of a simple selection "$".
The symbol "$" means pointer to selection. If you have only one node selected it's a pointer to node, if you have multiple selection it's a pointer to set of nodes. Because you need only one node of selection I used "selection[1]" which is equivalent to “$” in single selection case or “$[1]” in multi-selection case.
... i needed to make a local variable - "local segs".
Thanks again !
No. You don't need to define "local segs" inside loop. I did it automatically to make the code clear and cleaner for myself. But it doesn’t matter. To make the code working I changed “splineops.delete” to “modPanel.addModToSelection (deleteSplineModifier())”. “splineops.delete” doesn't work right in chain with "convertToMesh". Don't ask me why :).
CGTalk Moderation
07-13-2009, 06:14 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.