# How can I get or set the normals direction?

On 12/07/2018 at 08:45, xxxxxxxx wrote:

Hi everybody,I want to set normals direction of a model,but it is affected by a sub-division generator,I use python but I didn't find any function to achieve this,I have no idea about that,does anyone know how to solve that?If someone knows,please tell me!Thanks!

On 13/07/2018 at 03:08, xxxxxxxx wrote:

Hi, first of all, welcome in the PluginCafe forum BloomingShade.

Something important, you should make sure when you ask a question is to tell us in which context you are (a script, a generator?)

But in any, cases to set custom normal you have to use NormalTag.
Here a little example which writes your own normal

``````import c4d

def main() :
obj = op
if not obj:
return

polyCount = obj.GetPolygonCount()

tag = c4d.VariableTag(c4d.Tnormal, polyCount) # create tag
normals = list()

for polyIndex in xrange(polyCount) :
poly = obj.GetPolygon(polyIndex)

# Calculate vertex normal for each point
pointIndexArray = [poly.a, poly.b, poly.c, poly.d]

for pointIndex in pointIndexArray: # append vectors sequentially split
vNorms = c4d.Vector(1,0,0)
normals.append(vNorms.x)
normals.append(vNorms.y)
normals.append(vNorms.z)

obj.InsertTag(tag) # Apply tag
tag.SetAllHighlevelData(normals) # write normal to tag

if __name__=='__main__':
main()
``````

And here to read

``````import c4d

def main() :
obj = op
if not obj:
return

polyCount = obj.GetPolygonCount()

tag = obj.GetTag(c4d.Tnormal)

normals = tag.GetAllHighlevelData() # read normal from tag
for polyIndex in xrange(obj.GetPolygonCount()) :
poly = obj.GetPolygon(polyIndex)

pointIndexArray = [poly.a, poly.b, poly.c, poly.d]

for pointIndex in pointIndexArray:
vNorms = c4d.Vector(normals[pointIndex+polyIndex], normals[pointIndex+polyIndex+1], normals[pointIndex+polyIndex+2])
print "PolyID: {} - PtID: {} - {}".format(polyIndex, pointIndex, vNorms)

if __name__=='__main__':
main()
``````

If you have any question please let me know.
Cheers,
Maxime

On 13/07/2018 at 08:17, xxxxxxxx wrote:

Thank you for the welcome and thank you for the answer,it's kind of you!

In fact,I met a problem that after I change the direction of normals,I need to make my model become smooth,so I have to create a Subdivision Surface Generator,as soon as I create it,the normals direction changed again,it will be  affected by the generator so the direction will be out of control,will it be possible to solve this?Using script or using generator are both okay,whatever,I just want to solve it.

(Perhaps you have already known that my mother language is not English,so,if there are some mistakes in my sentences please don't mind.)