Hot News:

Unser Angebot:

  Foren auf CAD.de (alle Foren)
  Inventor .NET
  text wird nicht in textbox angezeit c#

Antwort erstellen  Neues Thema erstellen
CAD.de Login | Logout | Profil | Profil bearbeiten | Registrieren | Voreinstellungen | Hilfe | Suchen

Anzeige:

Darstellung des Themas zum Ausdrucken. Bitte dann die Druckfunktion des Browsers verwenden. | Suche nach Beiträgen nächster neuer Beitrag | nächster älterer Beitrag
  
Gut zu wissen: Hilfreiche Tipps und Tricks aus der Praxis prägnant, und auf den Punkt gebracht für Autodesk Produkte
Autor Thema:  text wird nicht in textbox angezeit c# (1601 mal gelesen)
dero2k
Mitglied
Technicher Zeichner ma bau


Sehen Sie sich das Profil von dero2k an!   Senden Sie eine Private Message an dero2k  Schreiben Sie einen Gästebucheintrag für dero2k

Beiträge: 53
Registriert: 24.04.2009

Inventor 2008 (hauptsächlich)
win xp

erstellt am: 12. Aug. 2012 03:52    Editieren oder löschen Sie diesen Beitrag!  <-- editieren / zitieren -->   Antwort mit Zitat in Fett Antwort mit kursivem Zitat    Unities abgeben: 1 Unity (wenig hilfreich, aber dennoch)2 Unities3 Unities4 Unities5 Unities6 Unities7 Unities8 Unities9 Unities10 Unities

Hallo liebes Forum

Ich habe mir ein kleines form erstellt womit ich dinge in die custom iproperties eintragen kann. dies klappt so weit auch ganz gut.

ich würde mir jetzt gerne fals bereits ein eintrag in den properties vorhanden ist diesen in den textboxen anzeigen lassen.

hier mal mein code

villeicht findet ja jemand den fehler 


Code:


namespace WindowsFormsApplication2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            // text in textboxen anzeien
            InitializeComponent();
           


            //einträge anzeigen

            // Connect to a running instance of Inventor.
            // Watch out for the wrapped line.
            Inventor.Application invApp = null;
            invApp = (Inventor.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application");

            // Get the active document.
            Inventor.Document doc = invApp.ActiveDocument;

            GetCustomiProperty(doc, "prop1", textBox1.Text);
            GetCustomiProperty(doc, "prop2", textBox2.Text);
            GetCustomiProperty(doc, "prop3", textBox3.Text);
            GetCustomiProperty(doc, "prop4", textBox4.Text);
            GetCustomiProperty(doc, "prop5", textBox5.Text);
            GetCustomiProperty(doc, "prop6", comboBox1.Text);
            GetCustomiProperty(doc, "prop7", textBox7.Text);
            GetCustomiProperty(doc, "prop8", textBox8.Text);
            GetCustomiProperty(doc, "prop9", textBox6.Text);
            GetCustomiProperty(doc, "prop10", textBox9.Text);
            GetCustomiProperty(doc, "prop11", comboBox2.Text);
            GetCustomiProperty(doc, "prop12", comboBox3.Text);
         


           

        }

        private void button1_Click(object sender, EventArgs e)
        {
            // Löschen ?

            // Connect to a running instance of Inventor.
            // Watch out for the wrapped line.
            Inventor.Application invApp = null;
            invApp = (Inventor.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application");

            // Get the active document.
            Inventor.Document doc = invApp.ActiveDocument;
           
            // Löschen ?

            // Update or create the custom iProperty.
           
            UpdateCustomiProperty(doc, "prop1", textBox1.Text);
            UpdateCustomiProperty(doc, "prop2", textBox2.Text);
            UpdateCustomiProperty(doc, "prop3", textBox3.Text);
            UpdateCustomiProperty(doc, "prop4", textBox4.Text);
            UpdateCustomiProperty(doc, "prop5", textBox5.Text);
            UpdateCustomiProperty(doc, "prop6", comboBox1.Text);
            UpdateCustomiProperty(doc, "prop7", textBox7.Text);
            UpdateCustomiProperty(doc, "prop8", textBox8.Text);
            UpdateCustomiProperty(doc, "prop9", textBox6.Text);
            UpdateCustomiProperty(doc, "prop10", textBox9.Text);
            UpdateCustomiProperty(doc, "prop11", comboBox2.Text);
            UpdateCustomiProperty(doc, "prop12", comboBox3.Text);
           

Form1.ActiveForm.Close();   
        }

        private void UpdateCustomiProperty(Inventor.Document Doc,
          String PropertyName,
          Object PropertyValue)
        {
            // Get the custom property set.
            // Watch out for the wrapped line.
            Inventor.PropertySet customPropSet;
            customPropSet = Doc.PropertySets["Inventor User Defined Properties"];

            // Get the existing property, if it exists.
            Inventor.Property prop = null;
            Boolean propExists = true;
            try
            {
                prop = customPropSet[PropertyName];
            }
            catch (Exception ex)
            {
                propExists = false;
            }

            // Check to see if the property was successfully obtained.
            if (!propExists)
            {
                // Failed to get the existing property so create a new one.
                prop = customPropSet.Add(PropertyValue, PropertyName, null);
            }
            else
            {
                // Change the value of the existing property.
                prop.Value = PropertyValue;
            }
        }


        // lese iprop

        private void GetCustomiProperty(Inventor.Document Doc,
          String PropertyName,
          Object PropertyValue)
            // string war object bei value
        {
            // Get the custom property set.
            // Watch out for the wrapped line.
            Inventor.PropertySet customPropSet;
            customPropSet = Doc.PropertySets["Inventor User Defined Properties"];

            // Get the existing property, if it exists.
            Inventor.Property prop = null;
            Boolean propExists = true;
            try
            {
                prop = customPropSet[PropertyName];
            }
            catch (Exception ex)
            {
                propExists = false;
            }

            // Check to see if the property was successfully obtained.
            if (!propExists)
            {
                // Failed to get the existing property so create a new one.
                prop = customPropSet.Add(PropertyValue, PropertyName, null);
            }
            else
            {
                // get the value of the existing property.

                PropertyValue = customPropSet[PropertyName].Value;
            }
        }



Danke schonmal

Dero

Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP

daywa1k3r
Moderator
Softwareentwickler




Sehen Sie sich das Profil von daywa1k3r an!   Senden Sie eine Private Message an daywa1k3r  Schreiben Sie einen Gästebucheintrag für daywa1k3r

Beiträge: 3497
Registriert: 01.08.2002

Desktop: 3.3GHz;8GB;SSD OCZ Vertex 3;Gainward Phantom GTX570
Laptop: Alienware m17x
Win7, Inventor2012

erstellt am: 12. Aug. 2012 09:52    Editieren oder löschen Sie diesen Beitrag!  <-- editieren / zitieren -->   Antwort mit Zitat in Fett Antwort mit kursivem Zitat    Unities abgeben: 1 Unity (wenig hilfreich, aber dennoch)2 Unities3 Unities4 Unities5 Unities6 Unities7 Unities8 Unities9 Unities10 Unities Nur für dero2k 10 Unities + Antwort hilfreich

Hallo,

jetzt mal rein theoretisch, ohne es getestet zu haben… Du könntest den dritten Parameter in den Funktionen von String auf Control umstellen, und gleich das Control selbst übergeben. Anschließend kannst du die Text Property von Control setzen, da Control das Basisobjekt ist und sowohl die TextBox als auch ComboBox davon ableiten.

Code:

        private void GetCustomiProperty(Inventor.Document Doc,
  String PropertyName,
   System.Windows.Forms.Control PropertyValueControl)
        // string war object bei value
        {
            object PropertyValue = PropertyValueControl.Text;
            // Get the custom property set.
            // Watch out for the wrapped line.
            Inventor.PropertySet customPropSet;
            customPropSet = Doc.PropertySets["Inventor User Defined Properties"];

            // Get the existing property, if it exists.
            Inventor.Property prop = null;
            Boolean propExists = true;
            try
            {
                prop = customPropSet[PropertyName];
            }
            catch (Exception ex)
            {
                propExists = false;
            }

            // Check to see if the property was successfully obtained.
            if (!propExists)
            {
                // Failed to get the existing property so create a new one.
                prop = customPropSet.Add(PropertyValue, PropertyName, null);
            }
            else
            {
                // get the value of the existing property.

                PropertyValue = customPropSet[PropertyName].Value;
            }
            PropertyValueControl.Text = PropertyValue.ToString();
        }


Der Aufruf sieht dann z.B. so aus:

Code:

GetCustomiProperty(doc, "prop1", textBox1);

PS: Wir haben hier auch ein .NET Forum...

------------------
Grüße Igor

FX64 Software Solutions - Inventor Tools
FX64 LambdaSpect - Lichtsimulation mit Autodesk Inventor

Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP

dero2k
Mitglied
Technicher Zeichner ma bau


Sehen Sie sich das Profil von dero2k an!   Senden Sie eine Private Message an dero2k  Schreiben Sie einen Gästebucheintrag für dero2k

Beiträge: 53
Registriert: 24.04.2009

Inventor 2008 (hauptsächlich)
win xp

erstellt am: 13. Aug. 2012 14:31    Editieren oder löschen Sie diesen Beitrag!  <-- editieren / zitieren -->   Antwort mit Zitat in Fett Antwort mit kursivem Zitat    Unities abgeben: 1 Unity (wenig hilfreich, aber dennoch)2 Unities3 Unities4 Unities5 Unities6 Unities7 Unities8 Unities9 Unities10 Unities

Dankeschön

Hat supper funktioniert 

und gut zu wissen das es hier auch ein .net forum gibt 

Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP

Anzeige.:

Anzeige: (Infos zum Werbeplatz >>)

Darstellung des Themas zum Ausdrucken. Bitte dann die Druckfunktion des Browsers verwenden. | Suche nach Beiträgen

nächster neuerer Beitrag | nächster älterer Beitrag
Antwort erstellen


Diesen Beitrag mit Lesezeichen versehen ... | Nach anderen Beiträgen suchen | CAD.de-Newsletter

Administrative Optionen: Beitrag schliessen | Archivieren/Bewegen | Beitrag melden!

Fragen und Anregungen: Kritik-Forum | Neues aus der Community: Community-Forum

(c)2023 CAD.de | Impressum | Datenschutz