Skip to content

Commit

Permalink
Updates to support Python 2 Better
Browse files Browse the repository at this point in the history
- Todo Fix Eyes being black .

Issue with Hex to Vector
  • Loading branch information
samjay3d committed May 29, 2021
1 parent 3325478 commit 2168106
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 24 deletions.
14 changes: 9 additions & 5 deletions Cinema 4D/appdir_common/plugins/DazToC4D/DazToC4D.pyp
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,17 @@ del blob, b, t, z, m

import importlib
import os
import sys

check = importlib.util.find_spec("ptvsd") is not None
if check:
import ptvsd
print("Python Version is {0}".format(sys.version_info))

ptvsd.enable_attach(address=("127.0.0.1", 3000))
ptvsd.wait_for_attach()
if sys.version_info > (3,0):
check = importlib.util.find_spec("ptvsd") is not None
if check:
import ptvsd

ptvsd.enable_attach(address=("127.0.0.1", 3000))
ptvsd.wait_for_attach()

import c4d

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def import_daz_fbx(self, file_path):
)

file = c4d.documents.LoadDocument(
file_path,
str(file_path),
flags,
)
c4d.documents.InsertBaseDocument(file)
Expand Down
16 changes: 11 additions & 5 deletions Cinema 4D/appdir_common/plugins/DazToC4D/lib/DazRig.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from ntpath import join
import c4d
from c4d import documents
import math
import sys

from .CustomCmd import Cinema4DCommands as dzc4d
from .CustomIterators import TagIterator
Expand Down Expand Up @@ -105,10 +105,16 @@ def reset_bind_pose(self, c_meshes):
for tag in tags:
tag_type = tag.GetTypeName()
if tag_type == "Weight":
tag[c4d.ID_CA_WEIGHT_TAG_SET_BUTTON] = 2005
c4d.CallButton(tag, c4d.ID_CA_WEIGHT_TAG_SET_BUTTON)
c4d.EventAdd()
break
if sys.version_info > (3,0):
tag[c4d.ID_CA_WEIGHT_TAG_SET_BUTTON] = 2005
c4d.CallButton(tag, c4d.ID_CA_WEIGHT_TAG_SET_BUTTON)
c4d.EventAdd()
break
else:
tag[c4d.ID_CA_WEIGHT_TAG_SET] = 2005
c4d.CallButton(tag, c4d.ID_CA_WEIGHT_TAG_SET)
c4d.EventAdd()
break

def fix_joints(self, c_skin_data, c_joints, c_meshes):
self.disable_skin_data(c_skin_data)
Expand Down
3 changes: 0 additions & 3 deletions Cinema 4D/appdir_common/plugins/DazToC4D/lib/DtC4DWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import c4d
from c4d import gui

from .Utilities import hideEyePolys
from .Materials import Materials, convertToRedshift, convertMaterials
from .CustomImports import CustomImports
from .DtC4DDialogs import EXTRADialog
Expand Down Expand Up @@ -395,13 +394,11 @@ def Command(self, id, msg):
convert_to_redshift = convertToRedshift()
convert_to_redshift.getBumpType(redshiftBumpType)
convert_to_redshift.execute()
hideEyePolys()
c4d.CallCommand(100004766, 100004766) # Select All
c4d.CallCommand(100004767, 100004767) # Deselect All

if comboRender == 3:
mat.convertToOctane()
hideEyePolys()
c4d.CallCommand(100004766, 100004766) # Select All
c4d.CallCommand(100004767, 100004767) # Deselect All

Expand Down
9 changes: 8 additions & 1 deletion Cinema 4D/appdir_common/plugins/DazToC4D/lib/Materials.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,14 @@ def srgb_to_linear_rgb(srgb):
def hex_to_col(hex, normalize=True, precision=6):
col = []
it = iter(hex)
if c4d.GetC4DVersion() >= 22123:
iterator = it.next()
else:
iterator = it.__next__()

for char in it:
col.append(int(char + it.__next__(), 16))
col.append(int(char + iterator, 16))

if normalize:
col = map(lambda x: x / 255, col)
col = map(lambda x: round(x, precision), col)
Expand Down Expand Up @@ -190,6 +196,7 @@ def find_mat_properties(self, obj, mat):

@staticmethod
def create_texture(mat, path):
path = str(path)
texture = c4d.BaseList2D(c4d.Xbitmap)
texture[c4d.BITMAPSHADER_FILENAME] = path
mat.InsertShader(texture)
Expand Down
9 changes: 0 additions & 9 deletions Cinema 4D/appdir_common/plugins/DazToC4D/lib/Utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,6 @@ def get_daz_name():
return ""


def hideEyePolys(self):
doc = documents.GetActiveDocument()
obj = doc.GetFirstObject()
scene = ObjectIterator(obj)
for obj in scene:
self.hidePolyTagByName(obj, "EyeMoisture")
self.hidePolyTagByName(obj, "Cornea")


def getJointFromSkin(obj, jointName):
objTags = TagIterator(obj)
for t in objTags:
Expand Down

0 comments on commit 2168106

Please sign in to comment.