internal static void InsertText(ViewBase view, Point point, string label)
        {
            try
            {
                string font       = String.Empty;
                double circleDiam = 0.0;
                double scale      = ((View)view).Attributes.Scale;

                TeklaStructuresSettings.GetAdvancedOption("XS_DIMENSION_FONT", ref font);
                TeklaStructuresSettings.GetAdvancedOption("XS_DRAWING_GRID_LABEL_FRAME_FIXED_WIDTH", ref circleDiam);

                Text text = new Text(view, point, label);
                Text.TextAttributes textAttributes = new Text.TextAttributes();
                textAttributes.Font = new FontAttributes(DrawingColors.Black, 5, font, false, false);
                text.Attributes     = textAttributes;

                if (circleDiam == 0)
                {
                    circleDiam = 5 * scale;
                }
                Circle circle = new Circle(view, point, 0.5 * circleDiam * scale);
                Circle.CircleAttributes circleAttributes = new Circle.CircleAttributes();
                circleAttributes.Line.Color = DrawingColors.Black;
                circle.Attributes           = circleAttributes;

                text.Insert();
                text.Modify();
                circle.Insert();
                circle.Modify();
            }
            catch { }
        }
예제 #2
0
        /*2016.6.21        /// <summary>
                /// ModAtrMD5() - calculate MD5 of the model read from Tekla in ModAtr
                /// </summary>
                /// <remarks>It could take few minutes for the large model</remarks>
                public static string ModAtrMD5()
                {
                    //            DateTime t0 = DateTime.Now;  
                    string str = "";
                    foreach (var att in ModAtr) str += att.mat + att.prf + att.lng.ToString();
                    ModelMD5 = Lib.ComputeMD5(str);
                    return ModelMD5;
                    //            new Log("MD5 time = " + (DateTime.Now - t0).ToString());
                } // ModAtrMD5
        2016.6.21 */
        public static string GetTeklaDir(ModelDir mode)
        {
            string TSdir = "";
            switch (mode)
            {
                case ModelDir.exceldesign:
// 6/4/17                    TeklaStructuresSettings.GetAdvancedOption("XS_EXTERNAL_EXCEL_DESIGN_PATH", ref TSdir);
                    TSdir = "C:\\ProgramData\\Tekla Structures\\2016i\\\\environments\\common\\exceldesign\\";
                    break;
                case ModelDir.model:
                    TSM.Model model = new TSM.Model();
                    ModInfo = model.GetInfo();
                    TSdir = ModInfo.ModelPath;
                    break;
                case ModelDir.macro:
                    TeklaStructuresSettings.GetAdvancedOption("XS_MACRO_DIRECTORY", ref TSdir);
                    string[] str = TSdir.Split(';');
                    TSdir = str[0] + @"\modeling";     // this Split is to ignore other, than common TS Enviroments
                    break;
                case ModelDir.environment:
                    TSdir = GetTeklaDir(ModelDir.exceldesign);
                    TSdir = Path.Combine(TSdir, @"..\..");
                    TSdir = Path.GetFullPath(TSdir);
                    break;
            }
            //////////            var ff = TeklaStructuresInfo.GetCurrentProgramVersion();
            //////////            var dd = TeklaStructuresFiles.GetAttributeFile(TSdir);
            //////////            TSdir = TS.TeklaStructuresFiles();
            return TSdir;
        }
예제 #3
0
        /// <summary>
        /// Runs the constructed macro.
        /// </summary>
        public void Run()
        {
            try
            {
                string Name       = GetMacroFileName();
                string MacrosPath = string.Empty;
                TeklaStructuresSettings.GetAdvancedOption("XS_MACRO_DIRECTORY", ref MacrosPath);

                File.WriteAllText(
                    Path.Combine(MacrosPath, Name),
                    "namespace Tekla.Technology.Akit.UserScript {" +
                    "public class Script {" +
                    "public static void Run(Tekla.Technology.Akit.IScript akit) {" +
                    this._Macro.ToString() +
                    "}" +
                    "}" +
                    "}"
                    );

                RunMacro("..\\" + Name);
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                String NameDll = Name.Substring(0, Name.Length - 2) + "dll";                                              // change by Domen Zagar. delete files after runing.
                String NamePdb = Name.Substring(0, Name.Length - 2) + "pdb";
                File.Delete(Path.Combine(MacrosPath, Name));
                File.Delete(Path.Combine(MacrosPath, NameDll));
                File.Delete(Path.Combine(MacrosPath, NamePdb));
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
            }
            catch (IOException Ex)
            {
                Debug.WriteLine(Ex);
            }
        }
        /// <summary>The get sys file path name.</summary>
        /// <param name="m">The m value.</param>
        /// <param name="name">The name value.</param>
        /// <returns>The System.String.</returns>
        public static string GetSysFilePathName(Model m, string name)
        {
            var result = string.Empty;

            string[] items = null;
            var      ii    = 0;

            while (true)
            {
                var path = string.Empty;

                if (ii == 0)
                {
                    path = m.GetInfo().ModelPath;
                }
                else if (ii == 1)
                {
                    TeklaStructuresSettings.GetAdvancedOption("XS_PROJECT", ref path);
                }
                else if (ii == 2)
                {
                    TeklaStructuresSettings.GetAdvancedOption("XS_FIRM", ref path);
                }
                else if (ii == 3)
                {
                    TeklaStructuresSettings.GetAdvancedOption("XS_SYSTEM", ref path);

                    // this might contain several folders
                    items = path.Split(new[] { ';' });
                    if (items.GetLength(0) > 0)
                    {
                        path = items[0];
                    }
                }
                else if (items.GetLength(0) > ii - 3)
                {
                    path = items[ii - 3];
                }
                else
                {
                    break;
                }

                if (path != string.Empty)
                {
                    var fullName = path + @"\" + name;
                    if (File.Exists(fullName))
                    {
                        result = fullName;
                        break;
                    }
                }

                ii++;
            }

            return(result);
        }
        private bool GetFullPathToExistingFile(string fileName, ref string fullPath)
        {
            var result        = false;
            var xsSystemPath  = string.Empty;
            var xsFirmPath    = string.Empty;
            var xsProjectPath = string.Empty;

            if (!fileName.StartsWith("\\"))
            {
                fileName = "\\" + fileName;
            }

            TeklaStructuresSettings.GetAdvancedOption(XsProject, ref xsProjectPath);
            TeklaStructuresSettings.GetAdvancedOption(XsFirm, ref xsFirmPath);
            TeklaStructuresSettings.GetAdvancedOption(XsSystem, ref xsSystemPath);

            if (
                File.Exists(
                    Application.ExecutablePath.Substring(
                        0, Application.ExecutablePath.LastIndexOf("\\", StringComparison.Ordinal)) + fileName))
            {
                fullPath = Application.ExecutablePath.Substring(
                    0, Application.ExecutablePath.LastIndexOf("\\", StringComparison.Ordinal)) + fileName;
            }

            if (File.Exists(this.currentModel.GetInfo().ModelPath + fileName))
            {
                fullPath = this.currentModel.GetInfo().ModelPath + fileName;
            }

            if (string.IsNullOrEmpty(fullPath))
            {
                fullPath = GetFullPath(xsProjectPath.Split(';'), fileName);
            }

            if (string.IsNullOrEmpty(fullPath))
            {
                fullPath = GetFullPath(xsFirmPath.Split(';'), fileName);
            }

            if (string.IsNullOrEmpty(fullPath))
            {
                fullPath = GetFullPath(xsSystemPath.Split(';'), fileName);
            }

            // No file found, default path modelpath
            if (string.IsNullOrEmpty(fullPath))
            {
                fullPath = this.currentModel.GetInfo().ModelPath + fileName;
            }
            else
            {
                result = true;
            }

            return(result);
        }
예제 #6
0
        private void BtnExportScript_Click(object sender, EventArgs e)
        {
            #region 테클라에 연결과 기본 모델의 경로, 버전 정보
            Model  model         = new Model();
            string modelname     = model.GetInfo().ModelName;
            string modelpath     = model.GetInfo().ModelPath;
            string configuration = ModuleManager.Configuration.ToString();
            string TSversion     = TeklaStructuresInfo.GetCurrentProgramVersion();
            string macrodir      = "";
            TeklaStructuresSettings.GetAdvancedOption("XS_MACRO_DRIECTORY", ref macrodir);

            #endregion

            string CNC_Files = "\\CNC_Output";
            if (!Directory.Exists(modelpath + CNC_Files))
            {
                Directory.CreateDirectory(modelpath + CNC_Files);
            }
            if (!File.Exists(modelpath + CNC_Files + @"\CreateDstv.cs"))
            {
                StreamWriter SW3 = new StreamWriter(modelpath + CNC_Files + @"\CreateDstv.cs");
                SW3.Write(Resources.CreateDSTV);
                SW3.Close();
            }

            StreamWriter SW4 = new StreamWriter(modelpath + @"\CNCProps");
            SW4.WriteLine("standard");
            SW4.WriteLine("");
            SW4.WriteLine(CNC_Files);
            SW4.Close();

            TSMO.Operation.RunMacro("CreateDstv.cs");

            while (TSMO.Operation.IsMacroRunning())
            {
            }
            if (MessageBox.Show("DSTV Export Complete. Do you want me to open the Folder?", "Export Complete Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                string filepath = modelpath + CNC_Files;
                System.Diagnostics.Process Explorer = new System.Diagnostics.Process();
                Explorer.EnableRaisingEvents = false;
                Explorer.StartInfo.FileName  = "explorer";
                Explorer.StartInfo.Arguments = filepath + "\\";
                Explorer.Start();
            }
        }
        /// <summary>Gets an environment variable.</summary>
        /// <param name="variableName">Variable name.</param>
        /// <value>Environment variable value.</value>
        /// <returns>The System.String.</returns>
        public string this[string variableName]
        {
            get
            {
                if (this.IsActive)
                {
                    var value = string.Empty;

                    if (
                        SeparateThread.Execute <bool>(
                            delegate { return(TeklaStructuresSettings.GetAdvancedOption(variableName, ref value)); }))
                    {
                        return(value);
                    }
                }

                return(string.Empty);
            }
        }
        /// <summary>
        /// Gets report directory path from given model.
        /// </summary>
        /// <param name="model">Model being in use.</param>
        /// <returns>Report directory path or empty string if failed to retrieve.</returns>
        public static string GetReportDirectory(this Model.Model model)
        {
            string reportDir = string.Empty;

            TeklaStructuresSettings.GetAdvancedOption("XS_REPORT_OUTPUT_DIRECTORY", ref reportDir);
            // If report directory is model-related, then there should be ".\" at the beginning of returned string
            if (reportDir.StartsWith(".\\"))
            {
                reportDir = model.GetInfo().ModelPath + reportDir.Substring(1);
            }
            // Check if report directory path is valid in both model-related and fixed path scenarios
            if (System.IO.Directory.Exists(reportDir))
            {
                return(reportDir);
            }
            else
            {
                return(string.Empty);
            }
        }
예제 #9
0
        /// <summary>
        /// Runs the constructed macro.
        /// </summary>
        public void Run()
        {
            try
            {
                string Name       = GetMacroFileName();
                string MacrosPath = string.Empty;
                TeklaStructuresSettings.GetAdvancedOption("XS_MACRO_DIRECTORY", ref MacrosPath);
                if (MacrosPath.Contains(";"))
                {
                    string[] temp = MacrosPath.Split(';');
                    foreach (string path in temp)
                    {
                        if (path.Contains(@"Environments\common\macros") || path.Contains(@"environments\common\macros"))
                        {
                            MacrosPath = path;
                            break;
                        }
                    }
                }

                File.WriteAllText(
                    Path.Combine(MacrosPath, Name),
                    "namespace Tekla.Technology.Akit.UserScript {" +
                    "public class Script {" +
                    "public static void Run(Tekla.Technology.Akit.IScript akit) {" +
                    this._Macro.ToString() +
                    "}" +
                    "}" +
                    "}"
                    );

                RunMacro("..\\" + Name);
            }
            catch (IOException Ex)
            {
                Debug.WriteLine(Ex);
            }
        }
예제 #10
0
        // <summary>
        // language from environment
        // </summary>

        /// <summary>
        /// The set language.
        /// </summary>
        public void SetLanguage()
        {
            var language = string.Empty;

            TeklaStructuresSettings.GetAdvancedOption("XS_LANGUAGE", ref language);

            switch (language)
            {
            case "ENGLISH":
                this.currentLanguage = "enu";
                break;

            case "DUTCH":
                this.currentLanguage = "nld";
                break;

            case "FRENCH":
                this.currentLanguage = "fra";
                break;

            case "GERMAN":
                this.currentLanguage = "deu";
                break;

            case "ITALIAN":
                this.currentLanguage = "ita";
                break;

            case "SPANISH":
                this.currentLanguage = "esp";
                break;

            case "JAPANESE":
                this.currentLanguage = "jpn";
                break;

            case "CHINESE SIMPLIFIED":
                this.currentLanguage = "chs";
                break;

            case "CHINESE TRADITIONAL":
                this.currentLanguage = "cht";
                break;

            case "CZECH":
                this.currentLanguage = "csy";
                break;

            case "PORTUGUESE BRAZILIAN":
                this.currentLanguage = "ptb";
                break;

            case "HUNGARIAN":
                this.currentLanguage = "hun";
                break;

            case "POLISH":
                this.currentLanguage = "plk";
                break;

            case "RUSSIAN":
                this.currentLanguage = "rus";
                break;

            default:
                this.currentLanguage = "enu";
                break;
            }
        }