Skip to content

Commit

Permalink
Тут поправил, там поломал
Browse files Browse the repository at this point in the history
  • Loading branch information
kuvbur committed May 3, 2020
1 parent 9bb5627 commit 407bae7
Show file tree
Hide file tree
Showing 14 changed files with 647 additions and 122 deletions.
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,11 @@ $RECYCLE.BIN/
*.lnk
*.gsm
*.xml
*.png
*.png

CONVERT/*
MODYFY_DATA/*
.spyproject/*
*.RPT
*.dbe
.pylint.d/*
2 changes: 1 addition & 1 deletion .spyproject/workspace.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ save_non_project_files = False

[main]
version = 0.1.0
recent_files = ['D:\\Рогожин ДА\\prog\\mygdisk\\Share\\pygdl\\batch_modify.py', 'D:\\Рогожин ДА\\prog\\mygdisk\\Share\\pygdl\\gdl_gsm.py', 'D:\\Рогожин ДА\\prog\\mygdisk\\Share\\pygdl\\convert_test.log']
recent_files = ['C:\\Users\\da-rogojin\\.spyder-py3\\temp.py', 'D:\\Рогожин ДА\\prog\\mygdisk\\Share\\pygdl\\Exemple\\MEP_param.py', 'D:\\Рогожин ДА\\prog\\mygdisk\\Share\\pygdl\\gdl_gsm.py']

Binary file removed CONVERT/xml/IDEntryList.dbe
Binary file not shown.
43 changes: 43 additions & 0 deletions Exemple/MEP_param.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# -*- coding: utf-8 -*-
import os
import batch_modify
import convert
import gdl_gsm

# =============================================================================
# Словари с добавляемым кодом, данными о параметрах и база подтипов
# =============================================================================
code_dic = batch_modify.get_code_dic()
param_dic = batch_modify.get_param_dic()
base = batch_modify.get_base() #База с именами подтипов

# =============================================================================
# Пути к объектам и временной папке
# =============================================================================
curr_dir = os.path.dirname(os.path.dirname(os.path.abspath (__file__)))
convert_temp_dir = os.path.abspath(os.path.join(curr_dir,'CONVERT','xml','Окна'))
convert_old_dir = os.path.abspath(os.path.join(curr_dir,'CONVERT','gsm','Окна'))
convert_new_dir = os.path.abspath(os.path.join(curr_dir,'CONVERT','gsm_out','Окна'))

el_add = ["Сегмент", "Фитинг", "Сочленения"]

#Конвертируем gsm в xml
convert.gsm2xml_batch(convert_temp_dir, convert_old_dir, 22)
for root, dirs, files in os.walk(convert_temp_dir):
for nm in files:
if nm.find(".xml")>0: #Рисунки и текстовые файлы не нужны
fname_xml = os.path.join(root, nm) #Полный путь к файлу
test_obj = gdl_gsm.gdl_gsm(fname_xml, base) #Экземпляр gsm объекта
mid = test_obj.get_An_MainGUID()
test_obj.set_param_dic(param_dic)
test_obj.close()
# flag_add = True
# for n in el_add:
# if name.find(n)!=-1: flag_add = True
# if name.find("Элемент Модели")==-1 and flag_add == True:
# test_obj.set_param_dic(param_dic) #Добавили параметры
# # test_obj.addcode_dic(code_dic) #Добавили код
# test_obj.close() #Закрыли с сохранением xml
# print(nm)
# #Конвертируем обратно в gsm с проеркой с записью отчёта в файл convert_test.log)
convert.finalizexml(convert_temp_dir,convert_new_dir,22, reportlevel=2, verbosityLevel=2)
61 changes: 61 additions & 0 deletions Exemple/batch_addparam.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 3 11:33:42 2019
@author: kuvbur
"""
import os
import convert
import batch_modify
import gdl_gsm
from shutil import copy
import subprocess
import sys

force_conv = True

# =============================================================================
# Имена файлов с параметрами
# =============================================================================
add_file = ['Перемычки']

# =============================================================================
curr_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
convert_temp_dir = os.path.abspath(os.path.join(curr_dir, 'CONVERT', 'xml'))
convert_old_dir = os.path.abspath(os.path.join(curr_dir, 'CONVERT', 'gsm'))
convert_new_dir = os.path.abspath(os.path.join(curr_dir, 'CONVERT', 'gsm_out'))
base = batch_modify.get_base()

param = {}
for from_fname in add_file:
abs_gsm_from_name = convert.get_fname_gsm(from_fname+".gsm")
abs_xml_from_name = convert.get_fname_xml(from_fname+".xml")
if os.path.isfile(abs_xml_from_name)==False or force_conv:
r =convert.gsm2xml(abs_xml_from_name,abs_gsm_from_name,22)
from_obj = gdl_gsm.gdl_gsm(abs_xml_from_name, base)
# param_from = from_obj.get_param_list()
# for k in param_from.keys():
# try:
# h = param_from[k]['Fix']
# except KeyError:
# param_from[k]['Fix'] = True
# if param_from[k]['Fix'] == False:
# param[k] = param_from[k]

# convert_temp_dir = os.path.abspath(os.path.join(curr_dir,'CONVERT','xml','conv'))
# convert_old_dir = os.path.abspath(os.path.join(curr_dir,'CONVERT','gsm','conv'))
# convert.gsm2xml_batch(convert_temp_dir, convert_old_dir, 22)
# for root, dirs, files in os.walk(convert_temp_dir):
# for nm in files:
# if nm.find(".xml")>0: #Рисунки и текстовые файлы не нужны
# fname_xml = os.path.join(root, nm) #Полный путь к файлу
# test_obj = gdl_gsm.gdl_gsm(fname_xml, base)
# test_obj.set_param_dic(param)
# test_obj.set_defult_pen()
# test_obj.close()
# copy(fname_xml, "D:\\xml")
# if os.path.isfile('D:\\gdl_log.txt'):
# os.remove('D:\\gdl_log.txt')
# p = subprocess.Popen("D:\\2gdl.bat", shell=True, stdout = subprocess.PIPE)
# stdout, stderr = p.communicate()

28 changes: 28 additions & 0 deletions Exemple/convert_gsm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 3 11:33:42 2019
@author: kuvbur
"""
import os

import convert

gsm_file_name = "аорtest.gsm"
version_to = 20

curr_dir = os.path.dirname(os.path.abspath (__file__))
os.chdir (curr_dir)
abs_gsm_file_name = convert.get_fname_gsm(gsm_file_name)
version_gsm, rezult = convert.get_version_gsm(abs_gsm_file_name)
if rezult:
print('Версия файла - %d' % (version_gsm))
fname_gsm_to = convert.convert_gsm(version_to, abs_gsm_file_name)
assert os.path.isfile(fname_gsm_to)
#if len(fname_gsm_to):
# version_gsm, rezult = convert.get_version_gsm(fname_gsm_to)
# print(version_gsm, rezult)
#convert.finalizexml(os.path.abspath(os.path.join(curr_dir,'CONVERT','xml')),os.path.abspath(os.path.join(curr_dir,'CONVERT','gsm_out')),version_to, reportlevel=1, verbosityLevel=2)
else:
print("Неизвестная версия")

72 changes: 72 additions & 0 deletions Exemple/param2csv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 3 11:33:42 2019
@author: kuvbur
"""
import os
import convert
import batch_modify
import gdl_gsm
import csv
from shutil import copy
import subprocess


force_conv = True

# =============================================================================
# Имена файлов с параметрами
# =============================================================================
add_file = ['Жб обрамление проёма', 'Перемычки', 'Параметры окна']

# =============================================================================
curr_dir = os.path.dirname(os.path.dirname(os.path.abspath (__file__)))
convert_temp_dir = os.path.abspath(os.path.join(curr_dir,'CONVERT','xml'))
convert_old_dir = os.path.abspath(os.path.join(curr_dir,'CONVERT','gsm'))
convert_new_dir = os.path.abspath(os.path.join(curr_dir,'CONVERT','gsm_out'))
base = batch_modify.get_base() #База с именами подтипов
# code_dic = batch_modify.get_code_dic()

param = {}
for from_fname in add_file:
abs_gsm_from_name = convert.get_fname_gsm(from_fname+".gsm")
abs_xml_from_name = convert.get_fname_xml(from_fname+".xml")
if os.path.isfile(abs_xml_from_name)==False or force_conv:
r =convert.gsm2xml(abs_xml_from_name,abs_gsm_from_name,22)
from_obj = gdl_gsm.gdl_gsm(abs_xml_from_name, base)
param_from = from_obj.get_param_list()
for k in param_from.keys():
try:
h = param_from[k]['Fix']
except KeyError:
param_from[k]['Fix'] = True
if param_from[k]['Fix'] == False:
param[k] = param_from[k]

# f_name = os.path.join('Окна','Параметры окна')
# abs_gsm_name = convert.get_fname_gsm(f_name+".gsm")
# abs_xml_name = convert.get_fname_xml(f_name+".xml")
# if os.path.isfile(abs_xml_name)==False or force_conv:
# convert.gsm2xml(abs_xml_name,abs_gsm_name,22)
# test_obj = gdl_gsm.gdl_gsm(abs_xml_name, base)
# test_obj.set_param_dic(param)
# test_obj.close()
# test_obj = gdl_gsm.gdl_gsm(abs_xml_name, base)

convert_temp_dir = os.path.abspath(os.path.join(curr_dir,'CONVERT','xml','conv'))
convert_old_dir = os.path.abspath(os.path.join(curr_dir,'CONVERT','gsm','conv'))
convert.gsm2xml_batch(convert_temp_dir, convert_old_dir, 22)
for root, dirs, files in os.walk(convert_temp_dir):
for nm in files:
if nm.find(".xml")>0: #Рисунки и текстовые файлы не нужны
fname_xml = os.path.join(root, nm) #Полный путь к файлу
test_obj = gdl_gsm.gdl_gsm(fname_xml, base)
test_obj.set_param_dic(param)
test_obj.close()
copy(fname_xml, "D:\\xml")
if os.path.isfile('D:\\gdl_log.txt'):
os.remove('D:\\gdl_log.txt')
p = subprocess.Popen("D:\\2gdl.bat", shell=True, stdout = subprocess.PIPE)
stdout, stderr = p.communicate()

34 changes: 34 additions & 0 deletions Exemple/place_object.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
"""
Created on Tue Apr 28 12:01:20 2020
@author: da-rogojin
"""
import lxml

coord = {'x':0, 'y':0, 'z':0}

root = lxml.etree.Element('PlacedObjects')
position_section = lxml.etree.SubElement(root, 'Position')
#Запись координат
for axsis,value in coord.items():
c = lxml.etree.SubElement(position_section, axsis)
c.text = str(value)

#Запись параметров
param_section = lxml.etree.SubElement(root, 'Parameters')

#Запись данных об элементе
libpart_section = lxml.etree.SubElement(root, 'LibPart')
gsm_abs_fname = lxml.etree.SubElement(libpart_section, 'Location')
pure_abs_fname = abs_fname.replace(' ', '%20')
gsm_abs_fname.text = 'lan.flat:///' + pure_abs_fname

# Запись в файл
lxml.etree.indent(root, space="\t")
txt = lxml.etree.tostring(root, encoding='UTF-8', xml_declaration=True).decode()
txt = txt.replace('[""', '["')
txt = txt.replace('""]', '"]')
txt = txt.replace('["]', '[""]')
with open("test.xml", 'tw', encoding='utf-8') as f:
f.write(txt)
9 changes: 9 additions & 0 deletions MODYFY_DATA/DataBase_MainGUID.csv
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,12 @@ B176ABF1-5813-478F-926B-28EE7C5DC1F7;???;0
B2970E4C-8680-4061-8670-2F4B638F3953;???;0
0DF8E541-68EB-4102-8886-C144F74770E0;???;0
51A838E5-0F40-4F6D-A658-CF2845581749;???;0
6ACDA889-69B2-4EC5-936C-CB1DA7032A92;???;0
F6AE9687-2BC7-4D47-88C9-8F793E1DE2D6;???;0
4ABD0A6E-634B-4931-B3AA-9BEE01F35CDF;???;0
7DDE9DC4-66BD-41C8-8376-46D0B352F69B;???;0
4D1E9F8F-3925-4CAC-8946-47EDE8C9D67C;???;0
1F5EFD4B-B9B7-4F9A-8979-F1AFBF053237;???;0
11E85B84-8DD1-491B-A2FE-337454A91545;???;0
7DA47A96-AA00-41C6-B8A3-5BCA55741AC8;???;0
01D4D825-6CD2-4961-B0B1-036C2C3C5DE7;???;0
Loading

0 comments on commit 407bae7

Please sign in to comment.