[Freecad] Реализован интерфейс добавления свойства (property) к фрейм объекту"
This commit is contained in:
parent
b744fe30a0
commit
7f13c0056f
4 changed files with 32 additions and 13 deletions
|
@ -28,19 +28,24 @@ def empty_importer(path_json):
|
|||
data = json.load(f)
|
||||
|
||||
pivot_name = data['label']
|
||||
pivot_parent_name = data['parent_label']
|
||||
pivot_pose = data['placement']
|
||||
loc = tuple(pivot_pose['position'].values())
|
||||
fori = tuple(pivot_pose['orientation'].values())
|
||||
bori = (fori[3],)+fori[:3]
|
||||
|
||||
bpy.ops.object.empty_add(
|
||||
type='ARROWS', radius=0.01, align='WORLD',
|
||||
type='ARROWS', radius=0.1, align='WORLD',
|
||||
location=(0, 0, 0), rotation=(0, 0, 0))
|
||||
pivot_obj = bpy.context.active_object # or bpy.context.object
|
||||
pivot_obj.name = pivot_name
|
||||
pivot_obj.rotation_mode = 'QUATERNION'
|
||||
pivot_obj.location = loc
|
||||
pivot_obj.rotation_quaternion = bori
|
||||
pivot_obj.rotation_mode = 'XYZ'
|
||||
|
||||
if pivot_parent_name:
|
||||
pivot_obj.parent = bpy.data.objects[pivot_parent_name]
|
||||
|
||||
f.close()
|
||||
logger.info('Point %s imported without errors', pivot_name)
|
||||
|
|
|
@ -37,13 +37,12 @@ class Frames(Workbench):
|
|||
import Frames
|
||||
self.framecommands = [
|
||||
"FrameCommand",
|
||||
"ASM4StructureParsing",
|
||||
"SelectedPartFrameCommand",
|
||||
"AllPartFramesCommand",
|
||||
"FeatureFrameCommand"
|
||||
]
|
||||
self.toolcommands = [
|
||||
"ExportPartInfoAndFeaturesDialogueCommand",
|
||||
"ExportPlacementAndPropertiesCommand",
|
||||
"ExportGazeboModels",
|
||||
"InsertGraspPose"
|
||||
]
|
||||
|
|
|
@ -174,10 +174,14 @@ def spawnClassCommand(classname, function, resources):
|
|||
|
||||
def getLocalPartProps(obj):
|
||||
old_placement = obj.Placement
|
||||
obj_parent_label = ''
|
||||
if obj.getParentGeoFeatureGroup():
|
||||
obj_parent_label = obj.getParentGeoFeatureGroup().Label
|
||||
# obj.Placement = FreeCAD.Placement()
|
||||
""" Part properties """
|
||||
partprops = {
|
||||
"label": obj.Label,
|
||||
"parent_label": obj_parent_label,
|
||||
"placement": placement2pose(old_placement),
|
||||
# "boundingbox": boundingBox2list(obj.Shape.BoundBox),
|
||||
# "volume": obj.Shape.Volume*1e-9,
|
||||
|
@ -465,7 +469,7 @@ def exportFeatureFramesDialogue():
|
|||
FreeCAD.Console.PrintMessage("Feature frames of " + str(unique_selected[0].Label) + " exported to " + str(ofile) + "\n")
|
||||
|
||||
|
||||
def exportPartInfoAndFeaturesDialogue():
|
||||
def exportPlacementAndProperties():
|
||||
"""Spawns a dialogue window for exporting both."""
|
||||
import Frames
|
||||
s = FreeCADGui.Selection.getSelection()
|
||||
|
@ -534,11 +538,11 @@ uidir = os.path.join(FreeCAD.getUserAppDataDir(),
|
|||
"Mod", __workbenchname__, "UI")
|
||||
icondir = os.path.join(uidir, "icons")
|
||||
|
||||
spawnClassCommand("ExportPartInfoAndFeaturesDialogueCommand",
|
||||
exportPartInfoAndFeaturesDialogue,
|
||||
spawnClassCommand("ExportPlacementAndPropertiesCommand",
|
||||
exportPlacementAndProperties,
|
||||
{"Pixmap": str(os.path.join(icondir, "parttojson.svg")),
|
||||
"MenuText": "Export info and featureframes",
|
||||
"ToolTip": "Export part properties (placement, C.O.M) and feature frames"})
|
||||
"MenuText": "Export placement and properties",
|
||||
"ToolTip": "Export object placement and properties and feature frames"})
|
||||
|
||||
spawnClassCommand("ExportGazeboModels",
|
||||
exportGazeboModels,
|
||||
|
|
|
@ -4,7 +4,7 @@ DESCRIPTION.
|
|||
Convert and setup FreeCAD solid objects to 3d assets mesh files.
|
||||
Support Blender compiled as a Python Module only!
|
||||
"""
|
||||
__version__ = "0.2"
|
||||
__version__ = "0.3"
|
||||
|
||||
import logging
|
||||
import os
|
||||
|
@ -33,21 +33,32 @@ def freecad_asset_pipeline(fcstd_path,
|
|||
blend_path=None,
|
||||
sdf_path=None):
|
||||
""" Setup FreeCAD scene to CG asset """
|
||||
# prepare blend file
|
||||
remove_collections()
|
||||
cleanup_orphan_data()
|
||||
|
||||
# import objects
|
||||
obj_importer(fcstd_path, tessellation)
|
||||
|
||||
if json_path is not None:
|
||||
for point in os.listdir(json_path):
|
||||
if point.endswith('.json'):
|
||||
empty_importer(point)
|
||||
# import lcs
|
||||
if json_path is None:
|
||||
json_path = os.path.dirname(fcstd_path)
|
||||
for f in os.listdir(os.path.dirname(fcstd_path)):
|
||||
if f.endswith('.json'):
|
||||
json_file = os.path.join(json_path, f)
|
||||
empty_importer(json_file)
|
||||
|
||||
# sdf setup WIP
|
||||
if sdf_path is not None:
|
||||
sdf_mesh_selector(sdf_path)
|
||||
|
||||
# retopo
|
||||
asset_setup()
|
||||
|
||||
# save blender scene
|
||||
if blend_path is not None:
|
||||
if not os.path.isdir(os.path.dirname(blend_path)):
|
||||
os.makedirs(os.path.dirname(blend_path))
|
||||
bpy.ops.wm.save_as_mainfile(filepath=blend_path)
|
||||
|
||||
# export all objects
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue