Tunnel removal and rollout issues

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

 
Thread Tools Search this Thread Display Modes
  1 Week Ago
Tunnel removal and rollout issues

Hi,

I have been using bits from this site and others to help me build a rollout that;
- removes the existing objects with names with variables ie. Fixed is "TUN_" then the spline used then "_SITE" and then the site name "A" which will be alphanumeric.
- reads textfile of the incoming tunnel spline
- directed to a function that then builds the tunnel segments
- lastly the segments are pathed to the spline

I had bits of this working but now nothing seems to work. I have stripped out bits added like close buttons and deletion of object lines of code but it has failed to return to working.
I have added close button and deletion to the code to make it easier for me to operate. The error comes with the uniquename however I suspect I have greater things wrong with it.
Could I get some tips tricks to assist me please?
the text file in essence is something like this;
TUN_MCD0-CRT_SITEA_SEC_1-#001|TUN_A_LIN_1-#001|6.2|6.5|470|245.314|515.152|43.036|472.4|247. 419|514|43.021|1.2|40|-5.332|2.70|0|0|0
TUN_MCD0-CRT_SITEA_SEC_1-#002|TUN_A_LIN_1-#002|6.2|6.5|471.2|246.366|514.576|43.029|473.6|24 8.471|513.423|43.013|1.2|40|-5.332|2.70|0|0|0
TUN_MCD0-CRT_SITEA_SEC_1-#003|TUN_A_LIN_1-#003|6.2|6.5|472.4|247.419|514|43.021|474.8|249.52 4|512.846|43.006|1.2|40|-5.332|2.70|0|0|0
TUN_MCD0-CRT_SITEA_SEC_1-#004|TUN_A_LIN_1-#004|6.2|6.5|473.6|248.471|513.423|43.013|476|250. 576|512.27|42.999|1.2|40|-5.332|2.70|0|0|0
TUN_MCD0-CRT_SITEA_SEC_1-#005|TUN_A_LIN_1-#005|6.2|6.5|474.8|249.524|512.846|43.006|477.2|25 1.628|511.693|42.992|1.2|40|-5.332|2.70|0|0|0
TUN_MCD0-CRT_SITEA_SEC_1-#006|TUN_A_LIN_1-#006|6.2|6.5|476|250.576|512.27|42.999|478.4|252.6 81|511.116|42.984|1.2|40|-5.332|2.70|0|0|0

The code


errorState = false
Global f
Global n
Global line_cnt
Global Tun_CTR
arr = #()
line_cnt=1
while line_cnt < arr.count do (
deleteItem arr line_cnt
line_cnt = line_cnt +1
)
rollout TUNN "Tunnel_Rings" width:325 height:229
(
label 'lbl1' "TUNNEL CREATOR" pos:[6,5] width:236 height:30 align:#left
groupBox 'grp1' "TUNNEL RING FILE" pos:[8,24] width:302 height:210 align:#left
button 'inputload' "LOAD" pos:[183,140] width:89 height:35 align:#left
editText 'Alignm' "" pos:[167,58] width:103 height:26 align:#left
label 'lbl2' "Alignment Name:" pos:[22,62] width:111 height:20 align:#left
label 'lbl3' "Site Name (denote 1 alpha character)" pos:[23,96] width:208 height:20 align:#left
label 'InputFile' "File Name" pos:[23,150] width:128 height:20 align:#left
editText 'Sit' "" pos:[242,92] width:28 height:26 align:#left
button 'btnClose' "Close" pos:[183,170] width:89 height:35 align:#left

on inputload pressed do
(
local dog = Sit.text
local cat = Alignm.text
 if dog == undefined or cat == undefined do (Messagebox "Site and Alignment are empty or contain errors" ; errorState = true)
-- delete existing objects with names
tunnum = "TUN_" + cat + "_SITE" + dog + "*"
delete (for o in objects where matchpattern o.name pattern:tunnum collect o)
tunlin = "TUN_" + dog + "_LIN*" 
delete (for o in objects where matchpattern o.name pattern:tunlin collect o)
n = getOpenFileName caption:"Open Tunnel Elements File:" types: "Text(*.txt)|*.txt|All files|*.*"
if n==undefined do (print "No File Chosen"; errorState = true)
f = openfile n mode:"r" 

 if f ==undefined do (print "File Not Found"; errorState = true)
--InputFile.text = f
try (

while not eof f and errorState do
(
 l = readline f
 data = filterstring l "|"
--/////////////////////////////////////////////////
 --TUN_SEC_A-#000|TUN_LIN_A-#000|1451.699|470.29|-8.361|1454.385|470.26|-8.523|10|11|3|0|11301
-- variables 
 global tunname = data[1] as string
global Tun_CTR = data[2] as string
 fie = data[6] as float
 fin = data[7] as float
 fiz = data[8] as float
 ene = data[10] as float
enn = data[11] as float
enz = data[12] as float
 global rad1 = data[3] as float
 global rad2 = data[4] as float
 global hgt = data[13] as float
global ro = data[16] as float
--\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\   
-- Create Tunnel CTR String
 myCTRTun= splineShape name: uniquename Tun_CTR
 addnewspline myCTRTun
 (
addknot myCTRTun 1 #corner #line (point3 fie fin fiz)
addknot myCTRTun 1 #corner #line (point3 ene enn enz)
)
updateshape myCTRTun

 z = tunelem rad1 rad2 hgt tunname Tun_CTR ro
clearselection ()
)
close f
 Messagebox "Tunnel Rings Created Successfully"
)
catch ()

)
on inputload pressed do
(
destroyDialog TUNN 
)
)
CreateDialog TUNN
Fn tunelem rad1 rad2 hgt tunname Tun_CTR ro =
(
arrTMP =#()
if $tunname* != undefined then delete $tunname*
mygroup = tunname

n=60 as integerAB=51.429 as float BC=51.429 as float CD=51.429 as floatHA= 51.429 as float
DE=51.429 as floatEF=44.554 as floatFG=13.749 as floatGH = 44.554 as float
Tu_AB = tunname + "_Sec_AB" as string
Tu_BC = tunname + "_Sec_BC" as string
Tu_CD = tunname + "_Sec_CD" as stringTu_DE = tunname + "_Sec_DE" as string Tu_EF = tunname + "_Sec_EF" as stringTu_FG = tunname + "_Sec_FG" as stringTu_GH = tunname + "_Sec_GH" as string
 sidHA = (HA/360)*n as integerTu_HA = tunname + "_Sec_HA" as stringsidGH = (GH/360)*(n+3) as integer
sidAB = (AB/360)*n as integersidBC = (BC/360)*n as integersidCD = (CD/360)*n as integersidDE = (DE/360)*n as integersidEF = (EF/360)*n as integersidFG = 8 
oCyl1=Tube smooth:on sides:sidAB capsegs:1 heightsegs:1 radius1:rad1 radius2:rad2 height:hgt mapcoords:on realWorldMapSize:on pos:[0,0,0] slice:on sliceFrom:-90 sliceTo:(-90-AB) name: Tu_AB
append arrTMP (Tu_AB)
oCyl2=Tube smooth:on sides:sidBC capsegs:1 heightsegs:1 radius1:rad1 radius2:rad2 height:hgt mapcoords:on realWorldMapSize:on pos:[0,0,0] slice:on sliceFrom:(-90-AB) sliceTo:(-90-AB-BC) name: Tu_BC 
 append arrTMP (Tu_BC)
oCyl3=Tube smooth:on sides:sidCD capsegs:1 heightsegs:1 radius1:rad1 radius2:rad2 height:hgt mapcoords:on realWorldMapSize:on pos:[0,0,0] slice:on sliceFrom:(-90-AB-BC) sliceTo:(-90-AB-BC-CD) name: Tu_CD
oCyl3.wirecolor = (color 0 0 255)
append arrTMP (Tu_CD)
oCyl4=Tube smooth:on sides:sidDE capsegs:1 heightsegs:1 radius1:rad1 radius2:rad2 height:hgt mapcoords:on realWorldMapSize:on pos:[0,0,0] slice:on sliceFrom:(-90-AB-BC-CD) sliceTo:(-90-AB-BC-CD-DE) name: Tu_DE
append arrTMP (Tu_DE)
oCyl5=Tube smooth:on sides:sidEF capsegs:1 heightsegs:1 radius1:rad1 radius2:rad2 height:hgt mapcoords:on realWorldMapSize:on pos:[0,0,0] slice:on sliceFrom:(-90-AB-BC-CD-DE) sliceTo:(-90-AB-BC-CD-DE-EF-6) name: Tu_EF
append arrTMP (Tu_EF)
-- Big bit to be tapered next key part
dg = 90 - (HA+GH+FG)
s = sliceModifier Slice_Type:2
x5= (rad1+ (rad2-rad1)/2)*sin(dg)
y5 = (rad1+ (rad2-rad1)/2)*cos(dg)
z5 = hgt/2
Wpos = [x5,y5,z5]
tm=(matrix3 [1,0,0] [0,1,0] [0,0,1] [x5,y5,z5]) 
yrots = (10 - (GH+HA) )+ FG 
print yrots
Wrot = (eulerangles 96 -71 90) as quat
 oCylob = oCyl5
addModifier oCyl5 s
objTM = oCyl5.objectTransform
modTM = getModContextTM oCylob s
s.Slice_Plane.rotation = Wrot * modTM - (inverse (objTM as quat)) 
s.Slice_Plane.pos = [x5,y5,z5]* (inverse objTM)
convertTo OCylob Editable_Poly

oCyl6=Tube smooth:on sides:sidFG capsegs:1 heightsegs:1 radius1:rad1 radius2:rad2 height:hgt mapcoords:on realWorldMapSize:on pos:[0,0,0] slice:on sliceFrom:(12-90-AB-BC-CD-DE-EF) sliceTo:(-90-AB-BC-CD-DE-EF-FG-6) name: Tu_FG
append arrTMP (Tu_FG)
dg = 90 - (HA+GH)
s = sliceModifier Slice_Type:2
x5= (rad1+ (rad2-rad1)/2)*sin(dg)
y5 = (rad1+ (rad2-rad1)/2)*cos(dg)
z5 = hgt/2
Wpos = [x5,y5,z5]
tm=(matrix3 [1,0,0] [0,1,0] [0,0,1] [x5,y5,z5]) 
yrots = (10 - (GH+HA) )+ FG 
print yrots
Wrot = (eulerangles 84 -84 90) as quat
 oCylobz = oCyl6
addModifier oCyl6 s
objTM = oCyl6.objectTransform
modTM = getModContextTM oCylobz s
s.Slice_Plane.rotation = Wrot * modTM - (inverse (objTM as quat)) 
s.Slice_Plane.pos = [x5,y5,z5]* (inverse objTM)
--convertTo OCylobz Editable_Poly
dg = 90 - (HA+GH+FG)
s = sliceModifier Slice_Type:3
x5= (rad1+ (rad2-rad1)/2)*sin(dg)
y5 = (rad1+ (rad2-rad1)/2)*cos(dg)
z5 = hgt/2
Wpos = [x5,y5,z5]
tm=(matrix3 [1,0,0] [0,1,0] [0,0,1] [x5,y5,z5]) 
Wrot = (eulerangles 96 -71 90) as quat
 oCylobz6 = oCylobz
addModifier oCylobz s
objTM = oCylobz.objectTransform
modTM = getModContextTM oCylobz6 s
s.Slice_Plane.rotation = Wrot * modTM - (inverse (objTM as quat)) 
s.Slice_Plane.pos = [x5,y5,z5]* (inverse objTM)
convertTo OCylobz6 Editable_Poly
OCylobz6.wirecolor = (color 255 0 0)

oCyl7=Tube smooth:on sides:10 capsegs:1 heightsegs:1 radius1:rad1 radius2:rad2 height:hgt mapcoords:on realWorldMapSize:on pos:[0,0,0] slice:on sliceFrom:(-90-AB-BC-CD-DE-EF-FG +12) sliceTo:(-90-AB-BC-CD-DE-EF-FG-GH) name: Tu_GH
append arrTMP (Tu_GH)
-- Big bit to be tapered next key part
dg = 90 - (HA+GH)
s = sliceModifier Slice_Type:3
x5= (rad1+ (rad2-rad1)/2)*sin(dg)
y5 = (rad1+ (rad2-rad1)/2)*cos(dg)
z5 = hgt/2
Wpos = [x5,y5,z5]
tm=(matrix3 [1,0,0] [0,1,0] [0,0,1] [x5,y5,z5]) 
Wrot = (eulerangles 84 -84 90) as quat
 oCylob7 = oCyl7
addModifier oCyl7 s
objTM = oCyl7.objectTransform
modTM = getModContextTM oCylob7 s
s.Slice_Plane.rotation = Wrot * modTM - (inverse (objTM as quat)) 
s.Slice_Plane.pos = [x5,y5,z5]* (inverse objTM)
convertTo OCylob7 Editable_Poly

oCyl8=Tube smooth:on sides:sidHA capsegs:1 heightsegs:1 radius1:rad1 radius2:rad2 height:hgt mapcoords:on realWorldMapSize:on pos:[0,0,0] slice:on sliceFrom:(-90-AB-BC-CD-DE-EF-FG-GH) sliceTo:(-90-AB-BC-CD-DE-EF-FG-GH-HA) name: Tu_HA
oCyl8.wirecolor == (color 0 255 0)
append arrTMP (Tu_HA)
for i = 1 to arrTMP.count do
(
theMod = SpacePathDeform()
thepath = getNodeByName Tun_CTR
maindude =getNodebyname arrTMP[1]
theObj = getNodebyname arrTMP[i]
theObjz = getNodebyname arrTMP[i]
 addModifier theObj theMod
theMod.path = thepath
theObj.modifiers[#Path_Deform_Binding].Percent_along_path = 0.0 --default: 0.0
theObj.modifiers[#Path_Deform_Binding].rotation = (ro) --default: rotc 
theObj.modifiers[#Path_Deform_Binding].axis = 2 -- default: 2
theObj.modifiers[#Path_Deform_Binding].Flip_deformation_axis = 1
theObj.transform = thepath.transform --MOVE TO PATH!
if i > 1 then (
theObjz.parent= maindude
)
theObjz.pivot = theObjz.center
clearselection()
)
 
  1 Week Ago
Please post in an appropriate software forum. General Discussion is not the place.
 
reply share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 08:54 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.