Message 1 of 3
Saving User Defined Properties in a Drawing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
i've wrote an addin to change some User Defined Properties in a drawing.
public Bewerkingen()
{
InitializeComponent();
}
public Bewerkingen(Application inventor)
{
InitializeComponent();
this.Shown += CreateUI;
Machinings = new string[5];
this.inventor = inventor;
DrawingDocument oDrawDoc = (DrawingDocument)inventor.ActiveDocument;
PropertySets oPropSets = oDrawDoc.PropertySets;
PropertySet oPropSet = oPropSets["User Defined Properties"];
Enumerator = oPropSet.GetEnumerator();
Enumerator.Reset();
Machinings[0] = "";
Machinings[1] = "";
Machinings[2] = "";
Machinings[3] = "";
Machinings[4] = "";
while (Enumerator.MoveNext())
{
prop = (Property)Enumerator.Current;
if (prop.DisplayName == "Bewerking1") Machinings[0] = prop.Expression ?? " ";
if (prop.DisplayName == "Bewerking2") Machinings[1] = prop.Expression ?? " ";
if (prop.DisplayName == "Bewerking3") Machinings[2] = prop.Expression ?? " ";
if (prop.DisplayName == "Bewerking4") Machinings[3] = prop.Expression ?? " ";
if (prop.DisplayName == "Bewerking5") Machinings[4] = prop.Expression ?? " ";
if (prop.DisplayName == "Aantal") Aantal = Int32.Parse(prop.Expression);
}
textboxAantal.Text = Aantal.ToString();
}
i create the UI programatically
public void CreateUI(object sender, EventArgs e)
{
this.Size = new Size(805, 650);
for (int i = 0; i < 5; i++)
{
GroupBox groupbox = new GroupBox();
groupbox.Name = "Bewerking" + (i + 1);
groupbox.Text = "Bewerking " + (i + 1);
groupbox.Location = new System.Drawing.Point(30 + (i * 150), 30);
groupbox.Size = new Size(130, 530);
for (int j = 0; j < 14; j++)
{
Button button = new Button();
button.Name = groupbox.Text + "button" + (j + 1);
button.Text = MachiningsNames[j];
button.Location = new System.Drawing.Point(10, 30 + j * 35);
button.Size = new Size(100, 30);
button.BackColor = System.Drawing.Color.FromArgb(200, 220, 220, 220);
button.ForeColor = System.Drawing.Color.FromArgb(200, 20, 20, 20);
button.Click += new EventHandler(NewButton_Click);
groupbox.Controls.Add(button);
}
this.Controls.Add(groupbox);
}
SetBackgroudButtons();
Label label = new Label();
label.Text = "Aantal : ";
label.Location = new System.Drawing.Point(30, 574);
label.Size = new Size(100, 50);
label.Font = new Font("Microsoft Sans Serif", 16, FontStyle.Bold);
label.ForeColor = System.Drawing.Color.FromArgb(200, 20, 20, 20);
this.Controls.Add(label);
textboxAantal.Location = new System.Drawing.Point(130, 570);
textboxAantal.Size = new Size(75, 50);
textboxAantal.Font = new Font("Microsoft Sans Serif", 16, FontStyle.Bold);
textboxAantal.ForeColor = System.Drawing.Color.FromArgb(200, 20, 20, 20);
textboxAantal.TextChanged += new EventHandler(AantalChanged);
this.Controls.Add(textboxAantal);
}
We have two workstations. On my workstation this works flawlessly (saving drawing as well). But on the other station, the properties get changed aswell, but when saving the drawing all properties gets cleared ??
How can the save action be responsible for 'clearing' the User Defined Properties ??
Johan