Hello,
I'm trying to create a stencil that looks like a cartesian plan. There are squares inside of the stencil with coordonates (eg.: A-1, A-2) and in those squares there are 36 smaller squares. So my stencils is 5 x 5 and each of them are separated in 6 x 6.
What I'm trying to do is; if I drop a shape on top of my stencil on square 12 of coordonates B-4. Is there a way I can link the shapesheet datas to write those informations on the dropped shape (I will make a text field in the shape). So my shape will have B-4/12 tag on it.
My coordonates (A-1, A-2, ..., and the 36 smaller squares inside) are stored in the shape sheet so I can link it easily, but how can I know that my shape is dropped on that coordonates/cells ?
Thanks
As far as I know, it takes code to do that. You want to look at Spatial Neighbors, https://docs.microsoft.com/en-us/office/vba/api/Visio.Shape.SpatialNeighbors (https://docs.microsoft.com/en-us/office/vba/api/Visio.Shape.SpatialNeighbors)
and related Spatial Properties, https://docs.microsoft.com/en-us/office/vba/api/visio.shape.spatialrelation (https://docs.microsoft.com/en-us/office/vba/api/visio.shape.spatialrelation)
Wapperdude
That looks like what I want to do. I will try to make this works for my project.
Thank you very much kind sir
It does kinda work. The fact that my grid is a group, it doesnt give me the sub-shapes (it only gives me the group shape) of the grid and that is what I want to know.
I can't ungroup the grid because I need to let the user show/hide the grid and thus being controlled by a shape sheet property.
There is my code if it can helps.
short spatialRelation = (short)Visio.VisSpatialRelationCodes.visSpatialOverlap;
if (IsCanvasPresentOnPage(VisioHelper.GetActivePage()))
{
Visio.Selection selection = equipment.SpatialNeighbors[spatialRelation, 0, 0];
if (selection.Count > 1)
{
string x = null, y = null;
int cellNumber = 0;
foreach (Visio.Shape s in selection)
{
if (s.HitTest(equipment.CellsU["PinX"].Result[""], equipment.CellsU["PinY"].Result[""], 0) == 2)
{
//MessageBox.Show(s.Name + " Inside");
if (s.Name.Contains("MediumCanvas"))
{
x = s.CellsU["Prop.xIndex"].ResultStr[""];
y = s.CellsU["Prop.yIndex"].ResultStr[""];
}
if (s.Name.Contains("SmallCanvas"))
{
cellNumber = s.CellsU["Prop.cellNumber"].ResultInt["", 0];
}
}
}
equipment.CellsU["Prop.controllerLocation"].Formula = "\"" + y + x + "/" + cellNumber + "\"";
}
}
equipment is the shape I need to know where it is positionned on the grid.