+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Forum Newbie
    Using
    MEP 2015
    Join Date
    Jan 2015
    Posts
    9

    Default Or Statement Not Working

    Registered forum members do not see this ad.

    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...

    Code:
    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.

  2. #2
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,723

    Default

    In lisp you would need another pair of brakets I think its the same here if ((.........< 2)) then
    A man who never made mistakes never made anything

  3. #3
    Forum Newbie
    Using
    MEP 2015
    Join Date
    Jan 2015
    Posts
    9

    Default

    Do you mean it should look something like this?

    Code:
    if ( con1 = ("TDC" or "Ductmate 35") ) and
    ((extin < 2 )) 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

  4. #4
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,723

    Default

    Dont program with this type of code method try this

    Code:
    if (( con1 = ("TDC" or "Ductmate 35") ) and (extin < 2 )) then
    A man who never made mistakes never made anything

  5. #5
    Forum Newbie
    Using
    MEP 2015
    Join Date
    Jan 2015
    Posts
    9

    Default

    Registered forum members do not see this ad.

    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...

    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...

    Code:
    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.

Similar Threads

  1. condition/and statement help?
    By LosGirk in forum AutoLISP, Visual LISP & DCL
    Replies: 2
    Last Post: 17th Sep 2014, 07:15 pm
  2. Conditional Statement
    By uuoo10levi in forum AutoLISP, Visual LISP & DCL
    Replies: 5
    Last Post: 9th Jan 2013, 05:23 am
  3. IF and COND - I need another statement...?
    By mrharris78 in forum AutoLISP, Visual LISP & DCL
    Replies: 5
    Last Post: 6th Dec 2012, 02:38 pm
  4. COND statement help
    By ssm-jt in forum AutoLISP, Visual LISP & DCL
    Replies: 6
    Last Post: 23rd Mar 2012, 03:38 pm
  5. Conditional statement
    By ketongin in forum AutoLISP, Visual LISP & DCL
    Replies: 18
    Last Post: 1st Nov 2011, 02:51 pm

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts