Creating an element with dynamic positioning variables

Creating an element with dynamic positioning variables

If an element (i.e. Rectangle) should be created via VBA and it should be positioned dynamically via variables it is important that those variables (XVariable, YVariable) have to be assigned prior to the element and afterwards assigning the scaling properties (XVarMin, XViewMin, XVarMax, XViewMax, YVarMin, .... )
If the scaling properties are assigned to the element prior the variables the behaviour in the Runtime will be different (reason for that is the calculation of the scaling properties).
Find below an example how to create such an element:
VBA Code:

Sub CreateRectangle()
Dim zPIC As DynPicture
Dim zELE As Element
Set zPIC = MyWorkspace.ActiveDocument.DynPictures.Item("MyPicture")
If zPIC Is Nothing Then Exit Sub

Set zELE = zPIC.Elements.Create("Rect_VBA", tpRectangle)
With zELE
'dynamic positioning variables
.XVariable = "x_dynamic_var"
.YVariable = "y_dynamic_var"

'static element properties
.Height = 100
.Width = 200
.DynProperties("StartX") = 0
.DynProperties("StartY") = 0

'dynamic width
.XZoomVariable = "width_var"
.XZoomVarMin = 0
.XZoomVarMax = 100
.XZoomViewMin = 0
.XZoomViewMax = 100

'dynamic height
.YZoomVariable = "height_var"
.YZoomVarMin = 0
.YZoomVarMax = 100
.YZoomViewMin = 0
.YZoomViewMax = 100

'x scaling position
.XVarMin = 0
.XViewMin = 0
.XVarMax = 1280
.XViewMax = 1280

'y scaling position
.YVarMin = 0
.YViewMin = 0
.YVarMax = 1024
.YViewMax = 1024
End With
Set zELE = Nothing
End Sub



This is a migrated post! Originally posted on 05.01.2009 by user herberto. 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