shoulda made myself clear. andnbsp;I didn’t say andquot;wouldnt this be a good idea?’ andnbsp;I said ‘someone do this for me’ <!– s:-) –><img src="{SMILIES_PATH}/icon_e_smile.gif" alt="" title="Smile" /><!– s:-) –>

anyway her is some code that seems to work. andnbsp;lazy stream of conscious programming. andnbsp;one hand typing so no comments snd shrt var nms. andnbsp;hell to debug. andnbsp;debug code still in if you want to uncomment.

try. let me know. andnbsp;hand hurts freom one hand typing so now got no good hands. andnbsp;just save as somethinf.cs in scripts dir. andnbsp;then select some vaguely coplanar points and run script.

george

—next line must be first in script

Language = VBScript

‘*********************************************************************************

‘ Purpose: Creates a Face from selectedc points

‘*********************************************************************************

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

andnbsp; andnbsp;Dim fso,db andnbsp;

andnbsp; andnbsp;const Pi= 3.14159265358979 andnbsp; andnbsp; ‘a greek delicacy

andnbsp; andnbsp;Dim PiOn2

andnbsp; andnbsp;PiOn2=Pi/2

andnbsp; andnbsp;Dim apc andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; ‘ActivePointCount

andnbsp; andnbsp;Dim info()

Sub Main (3DCApp)

andnbsp; andnbsp;Dim Scene andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;’The current active scene

andnbsp; andnbsp;Dim SceneRootGroup andnbsp; ‘The root Group of the scene

andnbsp; andnbsp;Dim Group andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;’The Group for our object (face)

andnbsp; andnbsp;Dim CopyGroup andnbsp; andnbsp; andnbsp; andnbsp;’where the face comes from

andnbsp; andnbsp;Dim Object andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; ‘The object we are creating (face)

andnbsp; andnbsp;Dim CopyObject

andnbsp; andnbsp;Dim Face andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; ‘The face we are creating andnbsp; andnbsp;

andnbsp;

andnbsp; andnbsp;Dim ii andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; ‘for looping

andnbsp; andnbsp;Dim GridOriginX andnbsp; andnbsp; andnbsp;’The 3DC Grid’s Origin (x)

andnbsp; andnbsp;Dim GridOriginY andnbsp; andnbsp; andnbsp;’The 3DC Grid’s Origin (y)

andnbsp; andnbsp;Dim GridOriginZ andnbsp; andnbsp; andnbsp;’The 3DC Grid’s Origin (z)

andnbsp; andnbsp;Dim GridSize andnbsp; andnbsp; andnbsp; andnbsp; ‘The 3DC Grid’s Size

andnbsp; andnbsp;Dim GridInterval andnbsp; andnbsp; ‘The 3DC Grid’s Interval

andnbsp; andnbsp;Dim Points andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; ‘The user’s desired # of points

andnbsp; andnbsp;Dim NumericPoints andnbsp; andnbsp;’Points converted to a number

andnbsp; andnbsp;Dim FirstPointX andnbsp; andnbsp; andnbsp;’First point in face

andnbsp; andnbsp;Dim FirstPointY andnbsp; andnbsp; andnbsp;’First point in face

andnbsp; andnbsp;Dim FirstPointZ andnbsp; andnbsp; andnbsp;’First point in face

‘ andnbsp; andnbsp;Dim AxisX andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;’Axis to rotate the start position around

‘ andnbsp; andnbsp;Dim AxisY andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;’Axis to rotate the start position around

‘ andnbsp; andnbsp;Dim AxisZ andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;’Axis to rotate the start position around

andnbsp; andnbsp;Dim Point andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;’Point we are creating

andnbsp; andnbsp;Dim gx andnbsp; andnbsp; andnbsp; andnbsp;’Group position

andnbsp; andnbsp;Dim gy andnbsp; andnbsp; andnbsp; andnbsp;’

andnbsp; andnbsp;Dim gz andnbsp; andnbsp; andnbsp; andnbsp;’

andnbsp; andnbsp;Dim BoxMinX andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;’The Object’s Bounding Box

andnbsp; andnbsp;Dim BoxMinY andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;’The Object’s Bounding Box

andnbsp; andnbsp;Dim BoxMinZ andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;’The Object’s Bounding Box

andnbsp; andnbsp;Dim BoxMaxX andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;’The Object’s Bounding Box

andnbsp; andnbsp;Dim BoxMaxY andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;’The Object’s Bounding Box

andnbsp; andnbsp;Dim BoxMaxZ andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;’The Object’s Bounding Box

andnbsp; andnbsp;Dim Material andnbsp; andnbsp; andnbsp; andnbsp; ‘The Face’s MaterialConst

andnbsp;

andnbsp;

andnbsp;

‘variables for file handling

‘ andnbsp; Set fso = CreateObject(andquot;Scripting.FileSystemObjectandquot;) andnbsp;

‘ andnbsp; andnbsp; Set db = fso.CreateTextFile(andquot;c:Program FilesAmabilisScriptsdb.txtandquot;,true)

andnbsp; andnbsp; andnbsp; andnbsp;’get the scene

andnbsp; andnbsp; andnbsp; andnbsp;Set Scene = 3DCApp.GetActiveScene

andnbsp; andnbsp; andnbsp; ‘get the active object count

andnbsp; andnbsp; andnbsp; andnbsp;apc = Scene.GetActivePointCount

‘ andnbsp; andnbsp; andnbsp; andnbsp;msgbox andnbsp;(andquot;apc andquot; andamp; apc)

andnbsp; andnbsp; andnbsp; If apc ] 2 Then

andnbsp; andnbsp; andnbsp; andnbsp;

andnbsp; andnbsp; andnbsp; andnbsp;redim info(apc,3) andnbsp; andnbsp; andnbsp; andnbsp;’x,y,z,angle

andnbsp; andnbsp; andnbsp; andnbsp;’get the root Group

andnbsp; andnbsp; andnbsp; andnbsp;Set SceneRootGroup = Scene.GetRootGroup

andnbsp; andnbsp; andnbsp; andnbsp;’create a Group for the object (face)

andnbsp; andnbsp; andnbsp; andnbsp;Set Group = Scene.CreateGroup

andnbsp; andnbsp; andnbsp; andnbsp;’add it to the scene

andnbsp; andnbsp; andnbsp; andnbsp;SceneRootGroup.AddChild Group

andnbsp; andnbsp; andnbsp; andnbsp;’give the Group a name – note that we can’t do this

andnbsp; andnbsp; andnbsp; andnbsp;’until the Group is added to the scene

andnbsp; andnbsp; andnbsp; andnbsp;Group.SetName andquot;FaceFromPoints Groupandquot;

andnbsp; andnbsp; andnbsp; andnbsp;’create an object

andnbsp; andnbsp; andnbsp; andnbsp;Set Object = Scene.CreateObject()

andnbsp; andnbsp; andnbsp; andnbsp;’add the face to the object

andnbsp; andnbsp; andnbsp; andnbsp;Set Face = Object.CreateFace

andnbsp; andnbsp; andnbsp; andnbsp;’add a dummy normal to the object (we need one to add the points)

andnbsp; andnbsp; andnbsp; andnbsp;Object.AddNormal 0,0,-1

andnbsp; andnbsp; andnbsp; andnbsp;Set CopyObject = Scene.GetActiveObject(0)

andnbsp; andnbsp; andnbsp; andnbsp;Set CopyGroup = CopyObject.GetParentGroup

andnbsp; andnbsp; andnbsp; andnbsp;CopyGroup.GetPosition nothing,gx,gy,gz andnbsp;

andnbsp; andnbsp; andnbsp; andnbsp;Group.SetPosition nothing,0,gx,gy,gz andnbsp; andnbsp; andnbsp;

andnbsp; andnbsp; andnbsp; andnbsp;mx=0 andnbsp;’means

andnbsp; andnbsp; andnbsp; andnbsp;my=0

andnbsp; andnbsp; andnbsp; andnbsp;mz=0

andnbsp; andnbsp; andnbsp; andnbsp;sdx=0 ‘standard devs

andnbsp; andnbsp; andnbsp; andnbsp;sdy=0

andnbsp; andnbsp; andnbsp; andnbsp;sdz=0

andnbsp; andnbsp; andnbsp; andnbsp;for ii=0 to apc-1 andnbsp; andnbsp; andnbsp;

andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; Point = Scene.GetActivePoint(ii)

andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; CopyObject.GetPoint Point, info(ii,0), info(ii,1), info(ii,2)

andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; mx=mx+info(ii,0)

andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; my=my+info(ii,1)

andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; mz=mz+info(ii,2)

andnbsp; andnbsp; andnbsp; andnbsp;Next

andnbsp; andnbsp; andnbsp; andnbsp;mx=mx/apc

andnbsp; andnbsp; andnbsp; andnbsp;my=my/apc

andnbsp; andnbsp; andnbsp; andnbsp;mz=mz/apc

‘msgbox (andquot;centre andquot; andamp; mx andamp; andquot; andquot; andamp; my andamp; andquot; andquot; andamp; mz)

andnbsp; andnbsp; andnbsp; andnbsp;for ii=0 to apc-1 andnbsp; andnbsp; andnbsp;

andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;sdx=sdx+(info(ii,0)-mx)^2

andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;sdy=sdy+(info(ii,1)-my)^2

andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;sdz=sdz+(info(ii,2)-mz)^2 andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;

andnbsp; andnbsp; andnbsp; andnbsp;Next

andnbsp; andnbsp; andnbsp; andnbsp;sdx=sdx/apc

andnbsp; andnbsp; andnbsp; andnbsp;sdy=sdy/apc

andnbsp; andnbsp; andnbsp; andnbsp;sdz=sdz/apc

‘msgbox (andquot;sds andquot; andamp; sdx andamp; sdy andamp; sdz)

andnbsp; andnbsp; andnbsp; andnbsp;if ((sdx[sdy) and [sdx[sdz)) then

andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;Axis=0

andnbsp; andnbsp; andnbsp; andnbsp;elseif ((sdy[sdx) and [sdy[sdz)) then

andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; Axis=1

andnbsp; andnbsp; andnbsp; andnbsp;else

andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; Axis=2

andnbsp; andnbsp; andnbsp; andnbsp;end if

‘msgbox(andquot;axis andquot; andamp; axis)

‘move to 000

andnbsp; andnbsp;

andnbsp; andnbsp; andnbsp; andnbsp;for ii=0 to apc-1

andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;info(ii,0)=info(ii,0)-mx

andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;info(ii,1)=info(ii,1)-my

andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;info(ii,2)=info(ii,2)-mz

andnbsp; andnbsp; andnbsp; andnbsp;next

andnbsp; andnbsp; andnbsp; andnbsp;for ii=0 to apc-1

andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; select case Axis

andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;Case 2 andnbsp; andnbsp; ‘min var in z

andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;if info(ii,0)=0 then

andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;info(ii,3)=0

andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; else

andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;info(ii,3)=atn(info(ii,1)/info(ii,0))

andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;info(ii,3) = QuadrantFix( info(ii,3),info(ii,1),info(ii,0) )

andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; end if

andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;Case 1 andnbsp; ‘min var in y

andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; if info(ii,2)=0 then

andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;info(ii,3)=0

andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; else

andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;info(ii,3)=atn(info(ii,0)/info(ii,2))

andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;info(ii,3) = QuadrantFix (info(ii,3),info(ii,0),info(ii,2))

andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; end if andnbsp;

andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;Case 0 andnbsp; andnbsp;’min var in x

andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;if info(ii,2)=0 then

andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;if info(ii,1)]0 then

andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;info(ii,3)=Pion2

andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; else info(ii,3)=Pi+Pion2

andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;end if andnbsp;

andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;else

andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;info(ii,3)=atn(info(ii,1)/info(ii,2))

‘ andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;db.writeline(andquot;opp andquot; andamp; info(ii,1) andamp; andquot; adj andquot; andamp; info(ii,2) andamp; andquot; ang andquot; andamp; info(ii,3))

andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;info(ii,3)= QuadrantFix (info(ii,3),info(ii,1),info(ii,2))

‘ andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;db.writeline(andquot;angle fixre andquot; andamp; info(ii,3))

andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;end if

andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;end select

andnbsp; andnbsp; andnbsp; andnbsp; next

andnbsp; andnbsp; andnbsp; andnbsp; sort info, apc

‘db.writeline(andquot;sortedandquot;)

for i=0 to apc-1

‘db.writeline(info(i,3))

next

andnbsp; andnbsp; andnbsp; andnbsp;for ii=0 to apc-1

andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;info(ii,0)=info(ii,0)+mx

andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;info(ii,1)=info(ii,1)+my

andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;info(ii,2)=info(ii,2)+mz

andnbsp; andnbsp; andnbsp; andnbsp;next

andnbsp; andnbsp; andnbsp; andnbsp; for ii=0 to apc-1 andnbsp; andnbsp; andnbsp;

andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;Object.AddPoint info(ii,0),info(ii,1),info(ii,2)

andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;Face.AddPointAndNormal ii,0

andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; ‘add the points and the normal to the fac\

andnbsp; andnbsp; andnbsp; andnbsp; Next

andnbsp; andnbsp; andnbsp; andnbsp;

andnbsp; andnbsp; andnbsp; andnbsp; ‘Create an appropriate material for the face

andnbsp; andnbsp; andnbsp; andnbsp; Set Material = Scene.CreateMaterial

andnbsp; andnbsp; andnbsp; andnbsp; ‘make it a nice color

andnbsp; andnbsp; andnbsp; andnbsp; Material.SetColor .894,.773,.788

andnbsp; andnbsp; andnbsp; andnbsp; ‘set the default diffuse value

andnbsp; andnbsp; andnbsp; andnbsp; Material.SetDiffuse 60

andnbsp; andnbsp; andnbsp; andnbsp; ‘set the default ambient value

andnbsp; andnbsp; andnbsp; andnbsp; Material.SetAmbient 20

andnbsp; andnbsp; andnbsp; andnbsp; ‘apply the material to the face

andnbsp; andnbsp; andnbsp; andnbsp; Face.SetMaterial Material

andnbsp; andnbsp; andnbsp; andnbsp; ‘add the object to the created Group

andnbsp; andnbsp; andnbsp; andnbsp; ‘this also triggers the update to the database

andnbsp; andnbsp; andnbsp; andnbsp; Group.AddObject Object

andnbsp; andnbsp; andnbsp; andnbsp;’set the object name – note that we can’t do this until

andnbsp; andnbsp; andnbsp; andnbsp;’the object is added to a Group

andnbsp; andnbsp; andnbsp; andnbsp; Object.SetName andquot;FaceFromPointsandquot;

andnbsp; andnbsp; andnbsp; andnbsp; ‘Now that we know the size of the object let’s set the position of the Group

andnbsp; andnbsp; andnbsp; andnbsp; ‘so the face is visible

andnbsp; andnbsp; andnbsp; andnbsp;

andnbsp; andnbsp; andnbsp; andnbsp;’get the 3DC grid details

‘ andnbsp; andnbsp; andnbsp; andnbsp;3DCApp.GetGridDetails GridOriginX, GridOriginY, GridOriginZ, GridSize, GridInterval

andnbsp; andnbsp; andnbsp; andnbsp;’get the object’s dimensions

‘ andnbsp; andnbsp; andnbsp; andnbsp;Object.GetBoundingBox BoxMinX, BoxMinY, BoxMinZ, BoxMaxX, BoxMaxY, BoxMaxZ

andnbsp; andnbsp; andnbsp; andnbsp;’Center the Object’s Group on the Scene and have the object sitting nicely

andnbsp; andnbsp; andnbsp; andnbsp;’on the surface

‘ andnbsp; andnbsp; andnbsp; andnbsp;Group.SetPosition SceneRootGroup, 0, GridOriginX + GridSize / 2, GridOriginY – BoxMinY, GridOriginZ + GridSize /2

andnbsp; andnbsp;else

andnbsp; andnbsp; msgbox andquot;need at least three pointsandquot;

andnbsp; andnbsp;End If andnbsp; andnbsp;

‘db.close

End Sub

sub sort(a(),points)

‘db.writeline(andquot;sortingandquot; andamp; points)

dim i

dim j

dim k

dim min

dim tempmin

dim temp()

redim temp(3)

‘redim buff(ipc,3)

‘for i=0 to points-1’ apc-1

‘ andnbsp;db.writeline(andquot;aandquot; andamp; a(i,3))

‘next

tempmin=0

for i=0 to points-2

andnbsp;min=i

andnbsp;tempmin=a(i,3)

andnbsp;for j=i+1 to points-1

andnbsp; andnbsp;if a(j,3)[tempmin then

andnbsp; andnbsp; andnbsp;min=j andnbsp;

andnbsp; andnbsp; andnbsp;tempmin=a(j,3)

andnbsp; andnbsp;end if

andnbsp;next andnbsp;

andnbsp;for k=0 to 3

andnbsp; andnbsp;temp(k)=a(i,k)

andnbsp; andnbsp;a(i,k)=a(min,k)

andnbsp; andnbsp;a(min,k)=temp(k)

andnbsp;next

next

‘db.writeline(andquot;sortedandquot; andamp; points)

‘for i=0 to points-1’ apc-1

‘ andnbsp; db.writeline(ii andamp; andquot;,andquot; andamp; a(i,0) andamp; andquot;,andquot; andamp; a(i,1) andamp; andquot;,andquot; andnbsp;andamp; a(i,2) andamp; andquot;,andquot;andamp; andnbsp;a(i,3))

‘next

end sub

function quadrantfix (ang, opp, adj)

if ((opp]0) and (adj[0)) then andnbsp;

andnbsp;ang=Pi+ ang

elseif((opp[0) and [adj[0)) then

andnbsp;ang=ang+Pi

elseif ((opp[0) and [adj]0)) then andnbsp;

andnbsp; ang=ang+ 2 * andnbsp;Pi

end if

quadrantfix = ang

end function

‘

code ends