-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
647 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,4 +139,11 @@ $RECYCLE.BIN/ | |
*.lnk | ||
*.gsm | ||
*.xml | ||
*.png | ||
*.png | ||
|
||
CONVERT/* | ||
MODYFY_DATA/* | ||
.spyproject/* | ||
*.RPT | ||
*.dbe | ||
.pylint.d/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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("Неизвестная версия") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.