Book a Demo

Author Topic: Can't create the Element "signal" with VBScript  (Read 3707 times)

game

  • EA User
  • **
  • Posts: 21
  • Karma: +0/-0
    • View Profile
Can't create the Element "signal" with VBScript
« on: March 16, 2020, 07:54:52 pm »
Hello,

I would like to create a new element of the type "Signal" using a VBScript.
Unfortunately it always brings me the standard message "This script does not support items of this type.

Has anyone given me a code snippet in which an element of the type Signal is created?

Many greetings

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Can't create the Element "signal" with VBScript
« Reply #1 on: March 16, 2020, 08:09:05 pm »
Hi,

Is this a browser script? If so, have you left the default code in there?
In that case you're probably running the script with the wrong type of item selected in the browser.

HTH,


/Uffe
My theories are always correct, just apply them to the right reality.

game

  • EA User
  • **
  • Posts: 21
  • Karma: +0/-0
    • View Profile
Re: Can't create the Element "signal" with VBScript
« Reply #2 on: March 16, 2020, 08:29:31 pm »
Thanks for pointing out that was the first problem.
I was able to fix that now.

Now it is so that when I want to add a signal, it always brings me the error that an object is missing.

Code: [Select]
case otPackage
' Code for when a package is selected

dim ElementSignal
ElementSignal = "Signal"

dim theElement as EA.Element
set theElement = theElement.Elements.AddNew(ElementSignal, "Test")
theElement.Update()
theElement.Packages.Refresh()

Where is my error?

Thanks

Arshad

  • EA User
  • **
  • Posts: 291
  • Karma: +21/-1
    • View Profile
Re: Can't create the Element "signal" with VBScript
« Reply #3 on: March 16, 2020, 10:09:44 pm »
you have missed assigning the selected package
Code: [Select]
dim thePackage as EA.Diagram
 set thePackage = Repository.GetTreeSelectedObject()
dim theElement as EA.Element
set theElement = thePackage.Elements.AddNew("Signal Name", "Signal")
theElement.Update()
thePackage.Elements.Refresh()


HTH
Arshad

game

  • EA User
  • **
  • Posts: 21
  • Karma: +0/-0
    • View Profile
Re: Can't create the Element "signal" with VBScript
« Reply #4 on: March 17, 2020, 12:40:42 am »
Thanks, that's how it worked now :-)