Author Topic: Slight issue with beginning to learn scripting  (Read 4061 times)

jplusip

  • EA User
  • **
  • Posts: 69
  • Karma: +0/-0
    • View Profile
Slight issue with beginning to learn scripting
« on: November 25, 2014, 06:36:31 am »
So I've decided to learn how to script for EA, and I'm just using VBScript within the tools scripting functionality (since for some reason I can't get Python to work; I think I need to download a win32 add-on or something).

Anyways, following qwerty's book I put in the code:
      root2 = Repository.Models.AddNew("A New Root", "")
      root2.Update()
      Repository.Models.Refresh()

and I get the error:

"Object doesn't support this property or method: 'root2', Line1"

I'm sure it's a novice error, but I'm not too familiar with VBScript, so if someone can point out to me what I'm doing wrong it would be greatly appreciated.

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: Slight issue with beginning to learn scripting
« Reply #1 on: November 25, 2014, 09:27:42 am »
You are missing the Set keyword.  You need it when assigning an object to a variable in VBScript.

Set root2 = Repository.Models.AddNew("A New Root", "")

jplusip

  • EA User
  • **
  • Posts: 69
  • Karma: +0/-0
    • View Profile
Re: Slight issue with beginning to learn scripting
« Reply #2 on: November 25, 2014, 09:34:34 am »
Quote
You are missing the Set keyword.  You need it when assigning an object to a variable in VBScript.

Set root2 = Repository.Models.AddNew("A New Root", "")

Thank you!

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Slight issue with beginning to learn scripting
« Reply #3 on: November 25, 2014, 08:56:55 pm »
Remember that I'm not using any specific code (that is: not VB script) but a pseudo code. You need to adapt the code examples like above adding SET in VB.

q.

jplusip

  • EA User
  • **
  • Posts: 69
  • Karma: +0/-0
    • View Profile
Re: Slight issue with beginning to learn scripting
« Reply #4 on: November 27, 2014, 05:20:27 am »
Quote
Remember that I'm not using any specific code (that is: not VB script) but a pseudo code. You need to adapt the code examples like above adding SET in VB.

q.

Oh I know. I'm just not very familiar with VBScript (which is why I originally tried to just use Python, but it wouldn't grab the API since I think I have to download something extra for win32com to work), and prior to just putting that exact code in I had try to set root2 with Dim root2 (which also didn't work).

But I'm good now!  8-) Thanks.
« Last Edit: November 27, 2014, 05:21:14 am by jplusip »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Slight issue with beginning to learn scripting
« Reply #5 on: November 27, 2014, 08:20:27 am »
Actually I also used python for a while. The crux with python is that you need an extra module for everything. And you can bet that the module you need is not available for the version you have currently installed. And cross-version there is nothing compatible with python. Though I think that the win32 stuff is available for any of the zillion python versions ;)

q.