AW: Events im Editor

AW: Events im Editor

Hallo,
erstmal Danke für die Hinweise. Das funktioniert alles soweit, auch das mit dem Wizard.:) Jetzt habe ich aber noch eine Sache die ich nicht nachvollziehen kann. Mit dem folgenden Quellcode erzeuge ich 2 Kreise und 1 Rechteck, die dann in einem Symbol ("Belt_Conveyor") zusammengefasst werden. Sobald ich die Element zu einem Symbol zusammenfasse, muss ich für die Eigenschaften .Left und .Top (für alle 3 Elemente) Werte angeben die ich durch ausprobieren herausgefunden habe. Leider verstehe ich nicht warum? Gebe ich diese Werte nicht an, werden die Elemente nicht zusammenhängend im Bild platziert. Bei dem Beispiel aus der VBA-Hilfe (Programmierschnittstellen -> Object Modell -> SymbolElements) passiert das gleiche. Woran kann das liegen?
VBA Code:
'œbergabeparameter: Breite und Höhe des Rechtecks
Private Function createBeltConvoyer(ByVal WIDTH_X As Integer, ByVal HEIGHT_Y As Integer)
Dim zPIC As DynPicture
Dim eleRec As Element
Dim eleCir1 As Element
Dim eleCir2 As Element
Dim zSymbol As Element
Const strPicture As String = "picStandardMixer1"
Const strElement As String = "Rectangle1"
Const STRCIR1 As String = "Circle1"
Const STRCIR2 As String = "Circle2"

'get Screen object
Set zPIC = MyWorkspace.ActiveDocument.DynPictures.Item(strPicture)
'if Screen object is nothing, the Screen doesn't exist...
If zPIC Is Nothing Then Exit Function
'get Element object
Set eleRec = zPIC.Elements.Item(strElement)
Set eleCir1 = zPIC.Elements.Item(STRCIR1)
Set eleCir2 = zPIC.Elements.Item(STRCIR1)
Set zSymbol = zPIC.Elements.Item("Belt_conveyor")
'if element object is nothing, a new one can be created...
If eleRec Is Nothing Then
'create a new element (Text-Button)
Set eleRec = zPIC.Elements.Create(strElement, tpRectangle)
'set properties of the new element
With eleRec
'set size and position
.Width = WIDTH_X
.Height = HEIGHT_Y
.Left = -200 + (HEIGHT_Y / 2)
.Top = -200
'set graphic representation
.BackColor = vbBlue
.ForeColor = vbBlack
End With
End If
If eleCir1 Is Nothing Then
'create a new element (Text-Button)
Set eleCir1 = zPIC.Elements.Create(STRCIR1, tpCircle)
'set properties of the new element
With eleCir1
'set size and position
.Height = HEIGHT_Y
.Width = HEIGHT_Y
.Left = -100
.Top = -100
'set graphic representation
.BackColor = vbBlue
.ForeColor = vbBlack
End With
End If

If eleCir2 Is Nothing Then
'create a new element (Text-Button)
Set eleCir2 = zPIC.Elements.Create(STRCIR2, tpCircle)
'set properties of the new element
With eleCir2
'set size and position
.Height = HEIGHT_Y
.Width = HEIGHT_Y
.Left = WIDTH_X
.Top = 0
'set graphic representation
.BackColor = vbBlue
.ForeColor = vbBlack
End With
End If

If zSymbol Is Nothing Then
'create symbol
Set zSymbol = zPIC.Elements.Create("Belt_conveyor", tpSymbol)
'set properties of the new symbol
With zSymbol
.Width = WIDTH_X + HEIGHT_Y
.Height = HEIGHT_Y
.Left = 100
.Top = 100
.Elements.Add eleRec
.Elements.Add eleCir1
.Elements.Add eleCir2
End With
End If

'save picture
zPIC.Save
End Function

VG

This is a migrated post! Originally posted on 30.01.2012 by user sniggi. Please be aware that information can be outdated.

    Disclaimer

    This document governs the use of our Community Forum. By registering and using the platform, you accept these conditions.

    The COPA-DATA Community Forum serves to encourage the exchange of information and experience about the zenon software between forum users respectively zenon users.

    Please mind that any published information on the Community Forum is the subjective opinion and view based on the experience and the level of knowledge of the author. COPA-DATA does not overtake any responsibility for the content and the accuracy of the shared information.

    Users of the Community Forum are encouraged to share only well-founded experiences and to point out any risks associated with the implementation of proposed solutions to problems. COPA-DATA at its absolute discretion, reserves the right to moderate the forum. In this connection COPA-DATA may remove any information containing false facts, potentially dangerous solutions, bad language or content that may insult, degrade or discriminate others. COPA-DATA may block a non-complying user from forum access if the user violated this provision.

    COPA-DATA reserves the right to change this document from time to time at own discretion.


    Ing. Punzenberger COPA-DATA GmbH
    Karolingerstraße 7b · 5020 Salzburg · Austria
    www.copadata.com