Place New Device View with Script

I will place the function "Place New Device View" on a shortcut. I'am a beginner with scripting. I tried the example from the help. But this one just create an new divece with a view. Have somebody a script like this or can help me?

greet from Switzerland

0

Comments

8 comments
  • I am not sure why you want to script that command; it s readily available on the device context menu.

    Anyway, for the example:

    1.  Replace the Dev.Create with a Job.GetSelectedDevices function.

    2  In the next line, have the id = the array element from the above function.

    This will make that example script work on whatever you have selected in your project..

    I am still not sure what your getting after though.  Are you just trying to learn some basic scripting?

    0
    Comment actions Permalink
  • Hi Paul

    Thanks. I want this function on a shortcut and to learn a little scripting.

    I now have this little Script, but this one give me just the Deviceid return. How can I open the window "New View" or how can I make a fixed view without open the window "New View"?

    Set e3 = CreateObject("CT.Application")
    Set Job = e3.CreateJobObject
    Set Dev = Job.CreateDeviceObject
    Set Sht = Job.CreateSheetObject
    Set sym = Job.CreateSymbolObject

    Job.GetSelectedDeviceIds( devIds )
    e3.PutMessage devIds(1)
    Dev.CreateView devIds(1), 1

    0
    Comment actions Permalink
  • Hi Sascha,

    Just a little note (since you are in "learning" mode..)

    No need to create a Sheet and a Symbol object if you do not use them later..

    That's all.. 

     

    Bye

    mm

    0
    Comment actions Permalink
  • Unfortunately, I don not believe there is any Place you could do on an existing device.  I am not sure if this would work but you could try placing the symbol so:

    The last line of your script above returns the id of the new view.

    Set that id and use the GetSymbolIds function, with the appropriate options, to retrieve the symbol(s) for that device view.

    Then, set the symbol id and  do a Sym.PlaceInteractively on the symbol id to attach it to the cursor.

     

    0
    Comment actions Permalink
  • Sorry, but i d'ont know,what you mean with set that id! The zuken support told me, its should work with the Sym.PlaceInteractively, but they dont give support on scripting.

    set e3 = CreateObject( "CT.Application" )
    set Job = e3.CreateJobObject
    Set Dev = Job.CreateDeviceObject
    Set Sym = Job.CreateSymbolObject

    e3.ClearOutputWindow

    If( Job.GetSelectedSymbolIds( devIds ) <> 1 ) then
    e3.PutWarning 0, "Please select one device."
    WScript.Quit
    End If

    e3.PutMessage devIds(1)
    Dev.CreateView devIds(1), 1
    Sym.SetId 1
    Job.GetSymbolIds devIds(1), "S_Anschlagteil_Temp","-1", "-1"
    Sym.SetId 1
    Sym.PlaceInteractively

    0
    Comment actions Permalink
  • Hello,

    This might help. I'm not sure if you are trying to place the device view or just a symbol of it?

    set e3 = CreateObject( "CT.Application" )
    set prj = e3.CreateJobObject
    Set sht = prj.CreateSheetObject
    Set dev = prj.CreateDeviceObject
    Set sym = prj.CreateSymbolObject


    If( prj.GetSelectedSymbolIds( devIds ) <> 1 ) then ' determine currently selected device
       e3.PutWarning 0, "Please select one symbol."
       WScript.Quit
    End If

    If( prj.GetSelectedSheetIds( shtids ) < 1 ) then ' determine current sheet
       e3.PutWarning 0, "Please select one device on a sheet."
       WScript.Quit
    Else
       shtid = shtids(1)
    End If

    dev.SetId devIds(1)
    id = dev.GetId

    viewId = dev.CreateView (id, 1) ' create device view #1 / won't work if view #1 exists already

    dev.SetId viewId

    compName = dev.GetComponentName
    compVersion = dev.GetComponentVersion

    dev.LoadAndPlaceComponent dev.GetName,dev.GetAssignment,dev.GetLocation,compName,compVersion,"",0,0 'name, assignment, location, comp, vers, wirename, after, options 

    0
    Comment actions Permalink
  • When you script in E3, before you execute a method that acts on a single object (Dev, Sym, etc.), you first need to set its internal ID (.SetId), making it the "active" object.  You usually will use some sort of Get function, like that GetSymbolIds, beforehand to retrieve what the ID is.

    0
    Comment actions Permalink
  • @Paul Thanks for your description

    @ Tyler I wont create a view (this works now) and then I wont to place this view not a new Symbol. Thanks for your Script. But your Script generate the Device View and a New Symbol.

    I cant find out, how i have to load the view to the cursor.

    set e3 = CreateObject( "CT.Application" )
    set Job = e3.CreateJobObject
    Set Dev = Job.CreateDeviceObject
    Set Sym = Job.CreateSymbolObject

    e3.ClearOutputWindow

    If( Job.GetSelectedSymbolIds( devIds ) <> 1 ) then
    e3.PutWarning 0, "Please select one device."
    WScript.Quit
    End If

    dev.SetId devIds(1)
    e3.PutMessage "devIds " & devIds(1)
    DevId = dev.GetId

    i = 1
    Do While CreateView <= 0
    createView = Dev.CreateView (DevId, i )
    Sym.SetId createView
    CreateId = Sym.GetId
    e3.PutMessage "createView " & createView
    i = i + 1
    Loop

    'GetSymbol = Job.GetSymbolIds (createView, "S_Anschlagteil_Temp","-1", "-1")
    'Sym.SetId GetSymbol
    'e3.PutMessage "GetSymbol " & GetSymbol

    symid = Sym.PlaceInteractively

    0
    Comment actions Permalink

Please sign in to leave a comment.

Didn't find what you were looking for?

New post