JohannWeiher

Über Johann Weiher

Der Autor hat bisher keine Details angegeben.
Bisher hat Johann Weiher, 533 Blog Beiträge geschrieben.

Weniger schlecht programmieren

Aufgrund eines aktuellen Projektes muss ich viel von meinem eigenen (alten) Code analysieren und Doku schreiben…
Sitze hier mit hochrotem Kopf und schäme mich… aber es geht wohl nicht nur mir so, sondern jeden Programmierer.

Im Urlaub habe ich angefangen das Buch “Weniger schlecht programmieren” angefangen zu lesen und es beschreibt die täglichen Probleme sehr gut / lustig / schön.

91o-ByjQXBL._SL1500_

Es ist auch hilfreich bei der Programmierung …
Mit viel Humor aber auch menschlichen Aspekten wird beschrieben wie man ein nicht ganz so schlechter Programmierer wird.

Amazon (Affiliat-Link)

Von |2015-06-15T07:39:20+02:002014-10-08|Allgemein|

Doorbell – Update: Pushbullet

Aufgrund eines Kommentars habe ich mir mal den Dienst Pushbullet angesehen.

Vorteil ist hier dass es eine Vorschau für Dateien (wie in unserem Fall Bilder) gibt.

Pushbullet

Leider gab es genau bei meinem Test ein Problem mit Pushnotifications unter iOS 8 … der Bug scheint behoben zu sein, dennoch pusht der Dienst nicht so zuverlässig wie Pushover. Ich teste nun ein bisschen mit beiden Diensten gleichzeitig. Aber eine Vorschau der Bilder ist natürlich schon ein Vorteil.

# Pushbullet
print("--> Pushbullet")
logger.info("--> Pushbullet")
pb = PushBullet("API-Token")

with open('/home/pi/Desktop/doorbell/web/photos/' +  filename, "rb") as pic:
    success, file_data = pb.upload_file(pic, filename + '.jpg')

success, push = pb.push_file(**file_data)
Von |2014-10-07T12:00:49+02:002014-10-07|Doorbell, Projekte, Raspberry Pi|

SetGrid

Unsere russischen Freunde von Eplan For All haben ein schönes Script geschrieben um die Raster-Größe anzupassen.

Download auf eplan4all.info

Vielen Dank!

 

//  Ersteller (разработчик):  madwolf_by aka Виталий
//  Datum:      2014-08-18 
//  www.eplan4all.info - Eplan For All


using Eplan.EplApi.Base;
using System.Windows.Forms;
using Eplan.EplApi.Scripting;
using Eplan.EplApi.ApplicationFramework;
using System;


public class SetGrid
{
    Settings oSettings = new Settings();
    string sPath = "USER.Control.UserGridSize";
    string sPath1 = "USER.Control.UserGridSizeMode";

    [DeclareRegister]
    public void Register()
    {
        if (!oSettings.ExistSetting(sPath))
        {
            if (!oSettings.ExistSetting(sPath))
                oSettings.AddStringSetting(sPath, new string[] { }, new string[] { }, "Current Gridsize", new string[] { @"4" }, ISettings.CreationFlag.Insert);
//            MessageBox.Show("Setting " + sPath + " registered");
        }

        if (!oSettings.ExistSetting(sPath1))
            oSettings.AddBoolSetting(sPath1, new bool[1], "UserGridSizeMode", new bool[1], ISettings.CreationFlag.Insert);

        return;
    }

    [DeclareUnregister]
    public void UnRegister()
    {
        if (oSettings.ExistSetting(sPath))
        {
            oSettings.DeleteSetting(sPath);
//            MessageBox.Show("Setting " + sPath + " unregistered");
        }
    }

    [DeclareAction("SetUserGridSize")]

    public void SetUserGrid(string GridSize)
    {
       
        if (oSettings.GetBoolSetting(sPath1, 0))
        {
            oSettings.SetStringSetting(sPath, GridSize, 0);
            //MessageBox.Show("Incoming param " + oSettings.GetDoubleSetting(sPath, 0));
            SetGridSizeToPage(GridSize);
        }

        else MessageBox.Show("Function is OFF", "SetGrid mode");
        
    }

    [DeclareAction("SetUserGridMode")]

    public void SetUserGridMode()
    {
        oSettings.SetBoolSetting(sPath1, !oSettings.GetBoolSetting(sPath1, 0), 0);
        if (oSettings.GetBoolSetting(sPath1, 0))
        {
            MessageBox.Show("Function is ON", "SetGrid mode");

        }

        else MessageBox.Show("Function is OFF", "SetGrid mode");

    }

    [DeclareEventHandler("onActionEnd.String.XGedNextPageAction")]
    public bool MyEventHandlerFunction1(IEventParameter iEventParameter)
    {
        SetGridSizeToPage(oSettings.GetStringSetting(sPath, 0));
        return true;
    }

    [DeclareEventHandler("onActionEnd.String.XGedPrevPageAction")]
    public bool MyEventHandlerFunction2(IEventParameter iEventParameter)
    {
        SetGridSizeToPage(oSettings.GetStringSetting(sPath, 0));
        return true;
    }

    [DeclareEventHandler("onActionStart.String.XPmPageOpenOnePage")]
    public bool MyEventHandlerFunction3(IEventParameter iEventParameter)
    {
        SetGridSizeToPage(oSettings.GetStringSetting(sPath, 0));
        return true;
    }
    

    public void SetGridSizeToPage(string paramValue)
    {
        if (oSettings.GetBoolSetting(sPath1, 0))
        {
            CommandLineInterpreter oCLI = new CommandLineInterpreter();
            ActionCallingContext oACC = new ActionCallingContext();
            string nameAction = "XEsSetPagePropertyAction";
            oACC.AddParameter("PropertyId", "11051");
            oACC.AddParameter("PropertyIndex", "0");
            //        MessageBox.Show("param from setting " +  Convert.ToString(oSettings.GetDoubleSetting(sPath, 0)));
            oACC.AddParameter("PropertyValue", paramValue);
            oCLI.Execute(nameAction, oACC);
        }
    }
}
Von |2017-11-09T12:23:41+01:002014-09-30|EPLAN, EPLAN-Scripts|

EplanCOMApplication

Oftmals muss man aus einer Applikation heraus EPLAN befeuern aufrufen und Actions ausführen.

Mit der COM Api von EPLAN ist dies möglich.

In Visual Studio müsst ihr den Verweis herstellen:

Verweise

Aufgerufen wird das ganze wie folgt:

EplanApplication eplanApplication = new EplanApplication();
eplanApplication.Show();
eplanApplication.ExecuteCommand("edit " +
                                "/PROJECTNAME:" + EplanProject +
                                " /DEVICENAME:" + SelectedFunction);

Zu beachten:

  • Ist EPLAN geöffnet wird dieser Prozess verwendet.
  • Ist EPLAN nicht geöffnet wird ein Prozess im Hintergrund gestartet und erst mit Show() sichtbar gemacht.
  • Wird beim Start des COM Objektes keine gültige Lizenz für EPLAN gefunden, bleibt das Programm stehen (muss abgeschossen werden).
Von |2017-11-09T12:23:42+01:002014-09-25|EPLAN, EPLAN-Scripts|

TranslateLanguages

Mit diesem Script können alle Sprachen des eingestellten Wörterbuchs abgerufen werden:

using Eplan.EplApi.Base;
using Eplan.EplApi.Scripting;
using System;
using System.Windows.Forms;

public class TranslateLanguages
{
    [Start]
    public void Execute()
    {
        Settings setting = new Settings();
        string stringSetting = setting.GetStringSetting("USER.TRANSLATE.TRANSLATE_LANGUAGES", 0);
        MessageBox.Show(stringSetting.Replace(";", Environment.NewLine));
    }
}

Translate_Languages

Von |2017-11-09T12:23:42+01:002014-09-22|EPLAN, EPLAN-Scripts|
Nach oben