Product : Engine, Version : 5.1.1.1042, ArticleID : 41024296

HowTo : SectionClips, how to use them and what is the CalculateNormal ?

Article41024296
TypeHowTo
ProductEngine
Version5.1.1.1042
Date Added9/22/2006
Submitted byCraig Willox
Keywords

Subject

SectionClips, how to use them and what is the CalculateNormal ?

Summary

I’m just trying to make a simple section clipping to restrict what can be shown and hidden at certain heights. But I can’t seem to get it to work correctly even in a very basic example. Are you able to see why the code below wouldn’t simply hide everything that isn’t between the heights of 5 and 10 DU?


        // Top Facing Down
        vdxyz pos1 = (vdxyz)vdPro.CreateInstance(VdConstObjectType.OBJ_XYZ);
        pos1.SetValueEx(0, 0, 10);
        vdxyz dir1 = (vdxyz)vdPro.CreateInstance(VdConstObjectType.OBJ_XYZ);
        dir1.SetValueEx(0, 0, -1);
        vdSectionClip clip1 = vdPro.ActiveDocument.Model.Sections.Add(DrawFunctions.GetUniqueDynamicBlockName(), pos1, dir1, 0);
 
        // Bottom Facing Up
        vdxyz pos2 = (vdxyz)vdPro.CreateInstance(VdConstObjectType.OBJ_XYZ);
        pos2.SetValueEx(0, 0, 5);
        vdxyz dir2 = (vdxyz)vdPro.CreateInstance(VdConstObjectType.OBJ_XYZ);
       
dir2.SetValueEx(0, 0, 1);
        vdSectionClip clip2 = vdPro.ActiveDocument.ActiveLayOut.Sections.Add(DrawFunctions.GetUniqueDynamicBlockName(), pos2, dir2, 0);

Do I need to set the surface area of the Section Clips at all? Or is it an infinite plane? Also, How does the last variable work (calculateNormal)? I can’t seem to find any documentation on it at all.

Solution

Try a code like :

private void button1_Click(object sender, EventArgs e)
{
    VD.ActiveDocument.New();
    VD.ActiveDocument.ActiveColor.ColorIndex = 1;
    VD.CommandAction.CmdSphere(new object[] { 0, 0, 7.5 }, 7.5, 20, 20);
    VD.CommandAction.Zoom("W", new object[] { -15, -15, 0 }, new object[] { 15, 15, 0 });   
    VD.CommandAction.View3D("VISE");
}

private void button4_Click(object sender, EventArgs e)
{
    VD.CommandAction.View3D("VROT");
}

private void button2_Click(object sender, EventArgs e)
{
    vdxyz pos1 = (vdxyz)VD.CreateInstance(VdConstObjectType.OBJ_XYZ);
    pos1.SetValueEx(0, 0, 10);
    vdxyz dir1 = (vdxyz)VD.CreateInstance(VdConstObjectType.OBJ_XYZ);
    dir1.SetValueEx(0, 0, -1);
    vdSectionClip clip1 = VD.ActiveDocument.Model.Sections.Add("TOP" , pos1, dir1, 0);
// Bottom Facing Up
    vdxyz pos2 = (vdxyz)VD.CreateInstance(VdConstObjectType.OBJ_XYZ);
    pos2.SetValueEx(0, 0, 5);
    vdxyz dir2 = (vdxyz)VD.CreateInstance(VdConstObjectType.OBJ_XYZ);
    dir2.SetValueEx(0, 0, 1);
    vdSectionClip clip2 = VD.ActiveDocument.Model.Sections.Add("BOTTOM", pos2, dir2, 0);
    VD.Redraw();
}

The CalculateNormal is used (and should be used) when the Direction is not a normal vector (when sqroot[x*x + y*y + z*z] <> 1 , where x,y,z are the values of the direction). So you can use it as in the example above (CalculateNormal = 0) or when you want the plane to be in (3,4,5) [<- Position] with direction another point  (6,7,8) [<-Direction] with CalculateNormal=1 
 
For example the lines above :
    pos1.SetValueEx(0, 0, 10);
    dir1.SetValueEx(0, 0, -1); // dir is a Normal Vector here
    vdSectionClip clip1 = VD.ActiveDocument.Model.Sections.Add("TOP" , pos1, dir1, 0);
Can be replaced with :
    pos1.SetValueEx(0, 0, 10);
    dir1.SetValueEx(0, 0, 0);  // dir is a point here
    vdSectionClip clip1 = VD.ActiveDocument.Model.Sections.Add("TOP" , pos1, dir1, 1);
 
The Section Clip plane is infinite.