Skip to content
This repository has been archived by the owner on May 18, 2019. It is now read-only.

Add LEGO logo to studs #122

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions import_ldraw.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,14 @@ def parse(self, filename):
subfiles.append(['orientation',
orientation, ''])

# Adds the LEGO logo on top of every stud. It is
# assumed that the logo3.dat file is available in
# the given p directory
if LogosOpt and new_file == "stud.dat":
mat_logo = self.mat * mathutils.Matrix(
((a,b,c,x),(d,e,f,y-4),(g,h,i,z),(0,0,0,1)))
subfiles.append(["logo3.dat", mat_logo, color])

# Triangle (tri)
if tmpdate[0] == "3":
self.parse_line(tmpdate)
Expand Down Expand Up @@ -825,7 +833,7 @@ def create_model(self, context, scale):
bpy.ops.mesh.select_all(action='SELECT')

# Remove doubles, calculate normals
bpy.ops.mesh.remove_doubles(threshold=0.01)
bpy.ops.mesh.remove_doubles(threshold=scale*0.005)
bpy.ops.mesh.normals_make_consistent()

if bpy.ops.object.mode_set.poll():
Expand Down Expand Up @@ -1038,6 +1046,12 @@ class LDRImporterOps(bpy.types.Operator, ImportHelper):
default=prefs.get("addGaps", False)
)

addLogos = BoolProperty(
name="LEGO Logo On Studs",
description="Add the LEGO logo on top of all studs",
default=prefs.get("addLogos", False)
)

lsynthParts = BoolProperty(
name="Use LSynth Parts",
description="Use LSynth parts during import",
Expand Down Expand Up @@ -1065,16 +1079,18 @@ def draw(self, context):
box.label("Additional Options", icon='PREFERENCES')
box.prop(self, "altColors")
box.prop(self, "addGaps")
box.prop(self, "addLogos")
box.prop(self, "lsynthParts")
box.prop(self, "linkParts")

def execute(self, context):
"""Set import options and start the import process."""
global LDrawDir, CleanUpOpt, AltColorsOpt, GapsOpt, LinkParts
global LDrawDir, CleanUpOpt, AltColorsOpt, GapsOpt, LogosOpt, LinkParts
LDrawDir = str(self.ldrawPath)
CleanUpOpt = str(self.cleanUpParts)
AltColorsOpt = bool(self.altColors)
GapsOpt = bool(self.addGaps)
LogosOpt = bool(self.addLogos)
LinkParts = bool(self.linkParts)

# Clear array before adding data if it contains data already
Expand Down Expand Up @@ -1136,6 +1152,7 @@ def execute(self, context):
# Create the preferences dictionary
importOpts = {
"addGaps": self.addGaps,
"addLogos": self.addLogos,
"altColors": self.altColors,
"cleanUpParts": self.cleanUpParts,
"importScale": self.importScale,
Expand Down