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.