Sparx Systems Forum

Enterprise Architect => General Board => Topic started by: Cisore on June 06, 2012, 12:09:42 am

Title: add Package in diagram Component with VBScript
Post by: Cisore on June 06, 2012, 12:09:42 am
Hello,

I don't arrived to add one package in diagram component with VBScript.

I arrived with a class. I have copy the code for the package but it's doesn't work !

Code: [Select]
     set digramHautNivo = newModel.Diagrams.AddNew( "hautNiveau", "Component" )
      digramHautNivo.Update()

      dim diagramObjects as EA.Collection
      set diagramObjects = digramHautNivo.DiagramObjects            
      
      dim packActivityDiagOb as EA.DiagramObject

        set packActivityDiagOb = diagramObjects.AddNew( "", "" )

      packActivityDiagOb.ElementID( PRow.PackageID )
      packActivityDiagOb.Update()

I have try the line "set packActivityDiagOb = diagramObjects.AddNew( "", "" )" with arguments :
"" , "Package"
"l=200;r=400;t=200;b=600;" , ""
"l=200;r=400;t=200;b=600;" , "Package"
"" , ""

I have replace the line "packActivityDiagOb.ElementID( PRow.PackageID )" with :
      packActivityDiagOb.ElementID( newPack.PackageID )
      packActivityDiagOb.InstanceID(newPack.PackageID)
      packActivityDiagOb.DiagramID(newPack.PackageID)

But no work.

Please help me  :'(
Title: Re: add Package in diagram Component with VBScript
Post by: qwerty on June 06, 2012, 08:16:55 am
In order to place a package you need to use the package's element, not the package. Get Package.Element and use the ElementID therein.

q.

P.S. I'm currently writing a book about EA scripting. It will take a couple of days until I'll publish the first version. But maybe it's soon enough to get you some more help.
Title: Re: add Package in diagram Component with VBScript
Post by: Cisore on June 06, 2012, 05:13:43 pm
It's work  :D Thanks.

Quote
P.S. I'm currently writing a book about EA scripting. It will take a couple of days until I'll publish the first version. But maybe it's soon enough to get you some more help.

I'm very interesting, I will be glad if you tell me the progress of you work.
(And if I can help you do not hesitate ... but I think not)
Title: Re: add Package in diagram Component with VBScript
Post by: Cisore on June 06, 2012, 09:56:02 pm
Again two questions  :-[ :

-Do you know how can I link two DiagramObjects ? I don't arrived with Connector !

-How can I change the effect of one Action (for Activity diagram) with a script ?
Title: Re: add Package in diagram Component with VBScript
Post by: qwerty on June 07, 2012, 12:03:34 am
I can answer only the first question: you need to create an object in DiagramLinks.

q.
Title: Re: add Package in diagram Component with VBScript
Post by: Cisore on June 07, 2012, 12:39:58 am
Quote
I can answer only the first question: you need to create an object in DiagramLinks.

q.

What is the difference bewteen DiagramLinks and Connector ?

Because it's possible to do the same work with :
Code: [Select]
     dim connector as EA.Connector
      set connector = diagram.Connectors.AddNew("","Import")
      connector.ClientID FirstElement.ElementID
      connector.SupplierID SecondeElement.ElementID
      connector.Update()
Title: Re: add Package in diagram Component with VBScript
Post by: qwerty on June 07, 2012, 02:48:55 am
Connector is the real connector. DiagramLinks is an instance used in a diagram (you can use it on multiple diagrams with different representations). Same applies for DiagramObjects.

q.
Title: Re: add Package in diagram Component with VBScript
Post by: Cisore on June 13, 2012, 05:54:30 pm
Quote
-How can I change the effect of one Action (for Activity diagram) with a script ?

I arrived to change action's effect BUT when I change for one action, the effect of all other exiting action are changed too.

Do you have any idea ?

the code :
Code: [Select]
     
dim p as EA._CustomProperty
for each p in elm.CustomProperties
      if(p.Name="effect") then
            p.Value="new effect"
      end if
next