How to determine a face’s normal?

Richard,

Thanks! Great support as usual!

Yes, I need the face, not vertex, normal. I’ll keep an eye out for 5.09.

Deanville

I’m trying to determine a selected face’s normal. The code snippet below tries to get the object index (I think) of the normal but results in an andquot;Object variable or With block variable not set (91)andquot; message when run. The code seems to follow that in the Direct-X script, what am I missing?

My assumption is that Face.GetNormal should yield an object normal index which can be used with
Object.GetNormal the_index, NormalX, NormalY, NormalZ. Thanks in advance!

Language = VBScript

‘********************************************************************************
‘ Purpose: Find normal of a face
‘********************************************************************************

Option Explicit andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;’require variable declarations

Sub Main (3DCApp)

andnbsp; andnbsp;Dim Scene, Object, Face
andnbsp; andnbsp;Dim ActiveObjectCount
andnbsp; andnbsp;Dim ActiveFaceCount
andnbsp; andnbsp;Dim Normal
andnbsp; andnbsp;Dim Nx andnbsp; andnbsp;’ returned X normal
andnbsp; andnbsp;Dim Ny andnbsp; andnbsp;’ returned Y normal
andnbsp; andnbsp;Dim Nz andnbsp; andnbsp;’ returned Z normal
andnbsp; andnbsp;Dim NLength ‘ Face’s normal length

andnbsp; andnbsp;’get the scene
andnbsp; andnbsp;Set Scene = 3DCApp.GetActiveScene

andnbsp; andnbsp;’get the active object count
andnbsp; andnbsp;ActiveObjectCount = Scene.GetActiveObjectCount

andnbsp; andnbsp;’get the active face count
andnbsp; andnbsp;ActiveFaceCount = andnbsp;Scene.GetActiveFaceCount

andnbsp; andnbsp;’only proceed if there is an active object and 1 active face
andnbsp; andnbsp;If ActiveObjectCount [] 1 Then

andnbsp; andnbsp; andnbsp; andnbsp;MsgBox andquot;Please select ONE object.andquot;

andnbsp; andnbsp;ElseIf ActiveFaceCount [] 1 Then

andnbsp; andnbsp; andnbsp; andnbsp;MsgBox andquot;Please select ONE face.andquot;
andnbsp;
andnbsp; andnbsp;Else

andnbsp; andnbsp; andnbsp; andnbsp;Set Object = Scene.GetActiveObject(0)
andnbsp; andnbsp; andnbsp; andnbsp;Set Face = Scene.GetActiveFace(0)

andnbsp; andnbsp; andnbsp; andnbsp;’ get 1st (and only?) normal
andnbsp; andnbsp; andnbsp; andnbsp;’ the statement below results in andquot;Object variable or
andnbsp; andnbsp; andnbsp; andnbsp;’ With block variable not setandquot; (91)
andnbsp; andnbsp; andnbsp; andnbsp;Normal = Face.GetNormal(0)
andnbsp; andnbsp; andnbsp;
andnbsp; andnbsp;End if
End Sub

deanville,
I believe that is an attribute of the forum software(built in foul language support). It tends to change certain words like andquot;a s sandquot; as in – assume. It does the same thing with andquot;c o c k pitandquot; as in – cockpit
Kinda cute huh?
Les……………….. ;D

How the heck did that happen? Please read andquot;assumeandquot; in lieu of andquot;disagreeumptionandquot; in the previous post.

Richard,

Thanks for the response, I’ll be looking for 5.09.

Deanville

Woops. That’s a bug. I’ll fix it for 5.0.9.

Sorry.

Richard

I have fixed this for 5.0.9 which should be available relatively soon. Also, I have added a new method andquot;GetFaceNormalandquot;. The only method was to get the face’s vertex normals. (a different thing and not likely what you were looking for).

Richard

You must be logged in to reply in this thread.