Jump to content

Recommended Posts

Fracture

I've made this script to adjust the extensions on our rectangular transition ducts but it doesn't want to work for me. Everything is fine if I keep it simple and leave out the " Or "Ductmate 35" " part but for this to work, I will need the or statement.

 

Anyways, here's the script...

 

select item.cid
case 2

	dim extin = item.dim[6].numvalue
	dim extout = item.dim[7].numvalue
	dim con1 = item.connector[1].value
	dim con2 = item.connector[2].value
	
	if ( con1 = ("TDC" or "Ductmate 35") ) and
	(extin < 2 ) then
	item.dim[6].value = 2
	end if

	if ( con2 = ("TDC" or "Ductmate 35") ) and
	(extout < 2 ) then
	item.dim[7].value = 2
	end if

	if ( con1 <> ("TDC" or "Ductmate 35") ) and
	(extin < 0.5 ) then
	item.dim[6].value = 0.5
	end if

	if ( con2 <> ("TDC" or "Ductmate 35") ) and
	(extout < 0.5 ) then
	item.dim[7].value = 0.5
	end if

	item.update()

end select

 

Can anyone spot the problem? I'm hoping its an embarrassingly simple one.

Share this post


Link to post
Share on other sites
BIGAL

In lisp you would need another pair of brakets I think its the same here if ((.........

Share this post


Link to post
Share on other sites
Fracture

Do you mean it should look something like this?

 

if ( con1 = ("TDC" or "Ductmate 35") ) and
[color="red"]((extin < 2 ))[/color] then
item.dim[6].value = 2
end if

 

I don't think putting something into two sets of brackets ((X)) would change the logic of the statement. I tried it just to be safe and there was no change.

 

Thanks for trying though :)

Share this post


Link to post
Share on other sites
BIGAL

Dont program with this type of code method try this

 

if (( con1 = ("TDC" or "Ductmate 35") ) and [color=red](extin < 2 ))[/color] then

Share this post


Link to post
Share on other sites
Fracture

Thanks for the tip. That actually looks a lot better and I changed my script to use the same format. Unfortunately it didn't fix the problem, but I think I figured out what is happening.

 

take a look at these two pieces of code...

 

if ( con2 = ("TDC" or "Ductmate 35") ) and
	(extout < 2 ) then
	item.dim[7].value = 2
	end if

;;;which is followed by...

if ( con2 <> ("TDC" or "Ductmate 35") ) and
	(extout < 0.5 ) then
	item.dim[7].value = 0.5
	end if

 

I think that the or statement may be working, but then I have a second line of code which is supposed to handle what happens if con2 does not equal TDC or Ductmate 35. I didn't take into account that this statement would be true whether the connector were TDC or Ductmate 35 because it can't be both. I probalby should of made that into an "and" statement.

 

Still, that would take a slightly chunkier piece of code. Do you know how I could use an else statement for this? I tried a few variations but kept getting errors I couldn't understand/fix.

 

This is what my script now looks like...

 

select item.cid
case 2

	dim extin = item.dim[6].numvalue
	dim extout = item.dim[7].numvalue
	dim con1 = item.connector[1].value
	dim con2 = item.connector[2].value
	
	if (( con1 = ("TDC" or "Ductmate 35")) and (extin < 2 )) then
	item.dim[6].numvalue = 2 elseif
	extin < 0.5 then
	item.dim[6].numvalue = 0.5
	end if

	if (( con2 = ("TDC" or "Ductmate 35")) and (extout < 2 )) then
	item.dim[7].numvalue = 2 elseif
	extout < 0.5 then
	item.dim[7].numvalue = 0.5
	end if


	item.update()

end select

 

Can you spot any syntax errors in that last script?

 

By the way, thanks for all of your help so far.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×