Book a Demo

Author Topic: Shape Script compare diagram name to shape name  (Read 3235 times)

Consult Douglas

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Shape Script compare diagram name to shape name
« on: October 24, 2014, 01:36:22 am »
I would like to have an if statement like
if (HasProperty("diagram.name", "#Name#")) {
    drawnativeshape();
}

It does not look like the property #Name# can be evaluated by the script engine to a string prior to it being passed to the function HasProperty.  Is this truly a limitation or is there another way to accomplish what I want.

In short, what I want is if I have a diagram named the same as my activity name (for me this diagram is the main diagram for the activity)  I want to draw the activity shape differently than when the activity is on another diagram.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Shape Script compare diagram name to shape nam
« Reply #1 on: October 24, 2014, 01:48:25 am »
You can implement an add-in and call it like
Quote
Code: [Select]
hasproperty('addin:myAddIn,pFunc2','1')will evaluate to true if your function pFunc2 returns the string value 1.
(from my Shape Script book)

q.

Consult Douglas

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: Shape Script compare diagram name to shape nam
« Reply #2 on: October 24, 2014, 04:39:54 am »
Thanks for confirming the limitation.  I'll go hunt down a free IDE to write a DLL in.

I bought your book today,  it mentions, what you've posted, is a way to extend shape script behavior.  But as you state, your book isn't about add-ins.  And I need to look elsewhere to figure out how to write/deploy the addin.

I am going to attempt to write an addin that will allow me to do the following in my shape scripts.

Code: [Select]
If (HasProperty("diagram.name", 'addin:myAddIn,toString', '#Name') {
  drawnativeshape();
}

Or will I need to write:
Code: [Select]
If (HasProperty('addin:myAddIn,compare','diagram.name','#Name') {
   drawnativeshape();
}


« Last Edit: October 24, 2014, 04:44:13 am by ead3 »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Shape Script compare diagram name to shape nam
« Reply #3 on: October 24, 2014, 05:51:39 am »
To start learning the API I sure can plug my Scripting book here :-) And for Add-ins you should look out for Geert Bellekens' great tutorial on his blog.

q.