Ruby Macro Busted After X15


Allen43
 Share

Recommended Posts

I recently updated to X15 and after doing so I have had a few problems. The last one I have to fix is my macro for auto cabinet label generation.

 

I am by no means a programmer and I barely understood ruby when I made this macro. I have been trying to relearn but I still can't figure out what my problem is.

I have attached my macro below and this is the error I have been getting:

 

Evaluation Error: Ruby TypeError: no implicit conversion of nil into String

Stack Trace:

from eval:10:in `eval'

from eval:10:in `block (2 levels) in <main>'

from eval:4:in `loop'

from eval:4:in `block in <main>'

 

Any help is apricated. Thanks in advance!

CabinetAutoLabel2.json

Link to comment
Share on other sites

46 minutes ago, Allen43 said:

I recently updated to X15

This looks like one of Joe's very old macros.. Object type no longer reports the same, so without a checksum for nil, it will throw an error.
might change the approach a bit, and redefine type in your code

Quote

# GET THE TYPE OF THE OBJECT, DOWNCASE, AND INDEX THE FIRST LETTER
type = obj.type.to_s.downcase[0]

and then when you analyze type later in the code

Quote

when 'w'

and maybe add a check for yourself:

 

Quote

 

# CHECK TO ENSURE VARIABLES ARE NOT NIL AND REPORT IF ANY IS NIL
if nomen.nil?
  puts "nomen is reporting nil and needs attention"
  nomen = ""
end

if width.nil?
  puts "width is reporting nil and needs attention"
  width = ""
end

if height.nil?
  puts "height is reporting nil and needs attention"
  height = ""
end

if depth.nil?
  puts "depth is reporting nil and needs attention"
  depth = ""
end

if hinging.nil?
  puts "hinging is reporting nil and needs attention"
  hinging = ""
end

 

 

Link to comment
Share on other sites

1 hour ago, Renerabbitt said:

This looks like one of Joe's very old macros.

Not mine, not by a long shot.

There are a lot of mistakes in this macro.  Some NVPs in X15 have different names than in X14, including the fact that the Base Cabinets type is now "Base cabinet".  it would be better to just assign:

  • nomen = obj.type[0].upcase

which would pick up B, W, F depending on the cabinet

Also, the line hinging = owner.door_swing 

 should be hinging = obj.door_swing

 

In my macros I use comprehensive error handling by use of:

 

begin

  some code...

rescue

  exception code...

end

 

so that my macros will never result in "evaluation error"

Link to comment
Share on other sites

3 hours ago, Renerabbitt said:

This looks like one of Joe's very old macros..

Now that you mention it, I do think I used one of his macros when making this one. But it has been terribly frankensteined into whatever this is. Haha

 

2 hours ago, Joe_Carrick said:

Not mine, not by a long shot.

Not yours, but it is based off of your macro. I couldn't find much info on macros in chief so I used yours as one of my only resources for how all of this worked.

 

2 hours ago, Joe_Carrick said:

begin

  some code...

rescue

  exception code...

end

This is really smart, and I should take the time to implement this in the new macro I am going to have to make.

 

2 hours ago, Joe_Carrick said:

nomen = obj.type[0].upcase

Great idea! I definitely should have done this.

 

2 hours ago, Joe_Carrick said:

Also, the line hinging = owner.door_swing 

 should be hinging = obj.door_swing

Thanks for letting me know! I'll make that change

 

3 hours ago, Renerabbitt said:
Quote

# GET THE TYPE OF THE OBJECT, DOWNCASE, AND INDEX THE FIRST LETTER
type = obj.type.to_s.downcase[0]

and then when you analyze type later in the code

Quote

when 'w'

and maybe add a check for yourself:

This is a much more concise approach that I will almost definitely implement this time.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share