Prod.: Engine, ver.: 6, ID: 60000970, HowTo : Hide specific XRref files from users

HowTo : Hide specific XRref files from users

Article60000970
TypeHowTo
ProductEngine
Version6
Date Added10/2/2009
Submitted bySteve Howarth
Keywords

Subject

Hide specific XRref files from users

Summary

Is it possible to delay the loading of xrefs until my program has a chance to decide which ones should be shown or not shown?

As far as I can tell, the afterOpenDocument function is called when the graphics file and all of its attachments have been loaded and converted. We would like to be able to hide certain files for certain users.

Solution

You can do this by setting to invisible the vdInserts of the XRef files (which are vsBlocks). Please check the code below:

(in an empty project add a vdFramed control and a button to open the drawing)

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication1
{
   public partial class Form1 :
Form
   {

public Form1()
{
   InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
   vdFramedControl1.BaseControl.ActiveDocument.Open(@"C:\321\xref\master.vdml");
}

private void Form1_Load(object sender, EventArgs e)
{
   vdFramedControl1.BaseControl.ActiveDocument.OnAfterOpenDocument += new VectorDraw.Professional.vdObjects.vdDocument.AfterOpenDocument(ActiveDocument_OnAfterOpenDocument);
}

void ActiveDocument_OnAfterOpenDocument(object sender)
{
   VectorDraw.Professional.vdObjects.vdDocument doc = (VectorDraw.Professional.vdObjects.vdDocument)sender;
   if (doc == null) return//something gone bad ?!?!
   if (doc.TopMostDocumet != doc) return; //do not run the code below for the xrefs but only for the "Master" drawing
  
//Create a selection
  
VectorDraw.Professional.vdCollections.vdSelection selset = new VectorDraw.Professional.vdCollections.vdSelection("Myselset");
   selset.SetUnRegisterDocument(vdFramedControl1.BaseControl.ActiveDocument);
  
//Create a filter
  
VectorDraw.Professional.vdObjects.vdFilterObject filter = new VectorDraw.Professional.vdObjects.vdFilterObject();
  
//Add vdInsert to select all polylines
  
filter.Types.AddItem("vdInsert");
  
//Apply the filter. After this the selection will contain the selected polylines.
  
selset.FilterSelect(filter);
   foreach (VectorDraw.Professional.vdFigures.vdInsert ins in selset)
   {
      if ((ins.Block.ExternalReference.FileName == @"C:\321\xref\circle1.vdml") || (ins.Block.ExternalReference.FileName == @"C:\321\xref\rect1.vdml"))
// here check what xrefs you don't want to show
      
{
         ins.visibility = VectorDraw.Professional.vdPrimaries.vdFigure.VisibilityEnum.Invisible;// here "set to invisible the xrefs"
         ins.Update();
      }
   }
}
}
}