Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Cura
CAD
CuraFreeCADPlugin
Commits
3b118e31
Commit
3b118e31
authored
May 26, 2019
by
Thomas Karl Pietrowski
Browse files
Cleanups and codestyle
Signed-off-by: Thomas Karl Pietrowski <thopiekar@gmail.com> (github: thopiekar)
parent
62495c97
Changes
2
Hide whitespace changes
Inline
Side-by-side
CuraFreeCADPlugin/FreeCADReader.py
View file @
3b118e31
...
...
@@ -5,26 +5,27 @@ import os
import
platform
# Uranium
from
UM.Application
import
Application
# @UnresolvedImport
from
UM.Logger
import
Logger
# @UnresolvedImport
from
UM.i18n
import
i18nCatalog
# @UnresolvedImport
from
UM.Version
import
Version
# @UnresolvedImport
from
UM.Application
import
Application
# @UnresolvedImport
from
UM.Logger
import
Logger
# @UnresolvedImport
from
UM.i18n
import
i18nCatalog
# @UnresolvedImport
from
UM.Version
import
Version
# @UnresolvedImport
# Since 3.4: Register Mimetypes:
if
Version
(
"3.4"
)
<=
Version
(
Application
.
getInstance
().
getVersion
()):
from
UM.MimeTypeDatabase
import
MimeTypeDatabase
,
MimeType
# C
adIntegrationUtils
from
.CadIntegrationUtils.CommonCLIReader
import
CommonCLIReader
# @UnresolvedImport
# C
IU
from
.CadIntegrationUtils.CommonCLIReader
import
CommonCLIReader
# @UnresolvedImport
i18n_catalog
=
i18nCatalog
(
"FreeCADPlugin"
)
class
FreeCADReader
(
CommonCLIReader
):
def
__init__
(
self
):
super
().
__init__
()
if
Version
(
"3.4"
)
<=
Version
(
Application
.
getInstance
().
getVersion
()):
MimeTypeDatabase
.
addMimeType
(
MimeType
(
name
=
"application/x-extension-fcstd"
,
MimeTypeDatabase
.
addMimeType
(
MimeType
(
name
=
"application/x-extension-fcstd"
,
comment
=
"FreeCAD files"
,
suffixes
=
[
"fcstd"
]
)
...
...
@@ -42,7 +43,7 @@ class FreeCADReader(CommonCLIReader):
return
super
().
openForeignFile
(
options
)
def
exportFileAs
(
self
,
options
,
quality_enum
=
None
):
def
exportFileAs
(
self
,
options
,
quality_enum
=
None
):
Logger
.
log
(
"d"
,
"Exporting file: %s"
,
options
[
"tempFile"
])
cli
=
'FreeCADCmd'
...
...
@@ -58,14 +59,18 @@ class FreeCADReader(CommonCLIReader):
"--stl"
,
options
[
"tempFile"
],
]
cwd
=
os
.
path
.
split
(
options
[
"foreignFile"
])[
0
]
try
:
ret
=
self
.
executeCommand
([
cli
,
]
+
opt
,
cwd
=
os
.
path
.
split
(
options
[
"foreignFile"
])[
0
]
,
cwd
=
cwd
,
)
except
:
cli
=
cli
.
lower
()
# Ubuntu: Command name is since bioic in lowercase.
# Ubuntu: Command name is since bioic in lowercase.
cli
=
cli
.
lower
()
ret
=
self
.
executeCommand
([
cli
,
]
+
opt
,
cwd
=
os
.
path
.
split
(
options
[
"foreignFile"
])[
0
]
,
cwd
=
cwd
,
)
if
ret
!=
0
:
Logger
.
log
(
"c"
,
"Returncode is not 0!"
)
CuraFreeCADPlugin/__init__.py
View file @
3b118e31
# Copyright (c) 2016 Thomas Karl Pietrowski
# Copyright (c) 2019 Thomas Karl Pietrowski
__plugin_name__
=
"FreeCAD plugin"
__plugin_id__
=
"CuraFreeCADPlugin"
# Uranium
from
UM.Platform
import
Platform
# @UnresolvedImport
from
UM.Logger
import
Logger
# @UnresolvedImport
from
UM.i18n
import
i18nCatalog
# @UnresolvedImport
i18n_catalog
=
i18nCatalog
(
"FreeCADPlugin"
)
from
UM.Platform
import
Platform
# @UnresolvedImport
from
UM.Logger
import
Logger
# @UnresolvedImport
from
UM.i18n
import
i18nCatalog
# @UnresolvedImport
i18n_catalog
=
i18nCatalog
(
__plugin_id__
)
# This plugins
from
.
import
FreeCADReader
def
getMetaData
():
return
{
"plugin"
:
{
"name"
:
i18n_catalog
.
i18nc
(
"@label"
,
"FreeCADPlugin"
)
,
"name"
:
__plugin_name__
,
"author"
:
"Thomas Karl Pietrowski"
,
"version"
:
"0.1.0"
,
"description"
:
i18n_catalog
.
i18nc
(
"@info:whatsthis"
,
"Gives you the possibility to open *.FCStd files."
),
"description"
:
i18n_catalog
.
i18nc
(
"@info:whatsthis"
,
"Gives you the possibility to open *.FCStd files."
),
"api"
:
3
},
"mesh_reader"
:
[
{
"extension"
:
"FCStd"
,
"description"
:
i18n_catalog
.
i18nc
(
"@item:inlistbox"
,
"FreeCAD files"
)
"description"
:
i18n_catalog
.
i18nc
(
"@item:inlistbox"
,
"FreeCAD files"
)
},
]
}
def
register
(
app
):
if
Platform
.
isWindows
()
or
Platform
.
isLinux
()
or
Platform
.
isOSX
():
from
.
import
FreeCADReader
# @UnresolvedImport
return
{
"mesh_reader"
:
FreeCADReader
.
FreeCADReader
()}
else
:
Logger
.
logException
(
"i"
,
"Unsupported OS!"
)
return
{}
metadata
=
[]
try
:
reader
=
FreeCADReader
.
FreeCADReader
()
metadata
[
"mesh_reader"
]
=
reader
except
:
Logger
.
logException
(
"e"
,
"An error occured, when loading the reader!"
)
return
metadata
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment