Vertex normal vector from vertex normal ID

Hi all,

I have a little issue I am stuck with.

I have an array of vertex notmal ID and I want to get their respectiv vectors.

exemple : ArrayVertNormalID = #(9, 64, 107, 1226) are the normals on my vert 1.
I am looking for : #([0.00180628,-0.00025264,-0.999998],[0.00116161,-0.00540292,-0.999985],
[0.00319966,0.0226716,-0.999738],[0.00180628,-0.00025264,-0.999998])
(random values.)

I have found this in the help but I am simply unable to find how to use it ! If I am not understanding it wrong it should give me my so desired point3 value from my normal index.

<point3>GetNormal <index>normalIndex [node:<node>]

node default value: undefined
Returns the specified indexed normal.
node :<node> is used when the Edit Normal modifier is applied to more than one node. For methods where this is a keyword argument, the operation is applied to the single node. Which node the operation applied to depends on the order in which the nodes were selected. As such, results can be unpredictable unless the node is specified.

any help much apreciated !
Thanks
Bloby

FOund it ! : )

Here’s how to write it :
<point3> = node.modifiers[#Edit_Normals].GetNormal <index>normalIndex [node:<node>]

It gives me well what I want. Damn I will never understand why the help don’t give you such things, in what twisted world this : <point3>GetNormal <index>normalIndex [node:<node>] is more helpful than this <point3> = node.modifiers[#Edit_Normals].GetNormal <index>normalIndex [node:<node>] ???

It’s not a usage case, it’s basically a method signature (one of many in the listing of the methods for the modifier class), <point3>GetNormal gives you the <return value>MethodName part, <index>normalIndex gives you <expected value>parameterName and [node:<node>] gives you optional keyword parameter and its expected value (btw. the notation is explained in the introduction part). Note that node.modifiers[#Edit_Normals] is a very specific case (will return 1st modifier named Edit Normals in the stack, no matter what class it is - and yes, modifiers get renamed quite frequently, too), even if you are creating it itself, it’s sort of a bad style - as soon as you create/assign the modifier, just stick it in a variable and use that.

Well, thanks very much for the explanation, as usual : ), still… I am not sure to get why not putting it directly as “usage case” :confused:

Usage cases are a bonus, they are nice to have but to include all the optional parameters, you’d have to list quite a few examples for each method.

Your problem is understanding bitarrays, I presume you wanted this (though I can only guess):

VertList = #{307, 311, 355, 384, 393, 404, 412,422, 436, 510, 528, 545, 549, 564}
TotalNormals = #{}
$.Edit_Normals.ConvertVertexSelection &VertList &TotalNormals
TotalNormals

However, looping For i = 1 to NormlIdVert.count do will do something completely different. First, bitarray.count gives you the length of the bitarray, no matter what’s the last index that’ set to true, so if the bitarray is #{false, true, false, false, false} (printed as #{2}), its .count will give 5. So if you get, for example, selected verts bitarray, its length will be the number off all verts - even in the case when just the first one is selected. If you wanted to loop over the indices in bitarray it’s just for i in bitarray do …, joining bitarrays is done with + operator and so on.

hehe thanks, but I found my problem : ) I have remove my post just after hopping no one would have seen it yet sorry :rolleyes:

But here’s the working code :

VertList = VertArray as array			
			
			NormlIdVert = #()	
			For my_verts = 1 to VertList.count do
			(	
				[B]TheVert = VertList[my_verts][/B]
				--define  empty bitArray to store the result					
				local my_normalsBit = #{}
				local VertBit = #{} 
				append VertBit [B]TheVert[/B]
				-- my_normals will contain the normal indices used by vertex my_verts ( After calling the method the second bitArray will contain the normals shared by the specified vertices.)
				MyObject.Edit_Normals.ConvertVertexSelection &VertBit &my_normalsBit				
				my_normals = my_normalsBit as array
				append NormlIdVert my_normals					
			)	

I simply didn’t get my item value and use the item ID instead. I am so ashamed. Didn’t pay attention :scared:

Thanks again for your precious help all time anyway :):