Imappopriate Source object for this Action (error message)

  • Thread starter shailendrasingh823
  • Start date
S

shailendrasingh823

Hi There,

I have more than 1 type connector including dynamic connector for
different conditions.like decide the connection type from a database
field( expmic or Logical).

GlueTo method is givinf me this exception " Imappopriate Source object
for this Action" when I try to execute
this code

private static void glueConnectionToItems(
Visio.Page drawingPage,Visio.Shape
connectionShape,
int fromShapeIndex,
int toShapeIndex)
{
try
{


// Glue the beginning of the connection to the "From"
shape.
Visio.Cell shapeCell =
drawingPage.Shapes[fromShapeIndex].get_CellsSRC(
(short)Visio.VisSectionIndices.visSectionObject,
(short)Visio.VisRowIndices.visRowXFormOut,
(short)Visio.VisCellIndices.visXFormPinX);
Visio.Cell connectorCell =
connectionShape.get_CellsSRC(
(short)Visio.VisSectionIndices.visSectionObject,
(short)Visio.VisRowIndices.visRowXForm1D,
(short)Visio.VisCellIndices.vis1DBeginX);
object obj = shapeCell.GetType();
connectorCell.GlueTo(shapeCell);

// Glue the end of the connection to the "To" shape.
shapeCell =
drawingPage.Shapes[toShapeIndex].get_CellsSRC(
(short)Visio.VisSectionIndices.visSectionObject,
(short)Visio.VisRowIndices.visRowXFormOut,
(short)Visio.VisCellIndices.visXFormPinX);
connectorCell =
connectionShape.get_CellsSRC(
(short)Visio.VisSectionIndices.visSectionObject,
(short)Visio.VisRowIndices.visRowXForm1D,
(short)Visio.VisCellIndices.vis1DEndX);
connectorCell.GlueTo(shapeCell);}

It's working for Dynamic Connector Shape instance but for Logical
Connector shape instance

It's giving me that message "Imappopriate Source object for this
Action ";

Please share if any idea.

Regards
Shail
 
P

Paul Herber

It's working for Dynamic Connector Shape instance but for Logical
Connector shape instance

It's giving me that message "Imappopriate Source object for this
Action ";

On the Logical Connector, set the ObjType to 2.

It's a bit of a bodge but it might just work.
 
S

shailendrasingh823

On the Logical Connector, set the ObjType to 2.

It's a bit of a bodge but it might just work.

Hi Paul,

Ca you tell me how can I do that because I am not getting any
setObjecttype option.

Here is my code----

private static bool addConnectionsToDrawing(
Visio.Page drawingPage)
{
bool connectionsAdded = false;

try
{
// Use the Connections master.
Visio.Master connectionMaster =

drawingPage.Document.Masters[_VisioConnectionMasterName];
Visio.Master LogicalconnectionMaster =

drawingPage.Document.Masters[_VisioLogicalConnectionMasterName];



if (connectionMaster != null ||
LogicalconnectionMaster!=null)
{
// Get the information about the connection data
from the
// linked data recordset.
Visio.DataRecordset connectionsDataRecordset =
drawingPage.Document.DataRecordsets[
_ConnectionsDataRecordsetIndex];

int nameColumnIndex;
int fromColumnIndex;
int toColumnIndex;
Visio.Shape newShape=null;


getConnectionColumnIndicies(connectionsDataRecordset,
out nameColumnIndex, out fromColumnIndex,
out toColumnIndex);

// Loop through each Connection in the Connection
table,
// dropping new shapes in random locations.
Random randomLocation = new Random();
Array rowIDs =
connectionsDataRecordset.GetDataRowIDs(string.Empty);

foreach (int thisRowID in rowIDs)
{
// Populate the shape with information from
the data row.
Array rowData =
connectionsDataRecordset.GetRowData(thisRowID);
if (((string)rowData.GetValue(4))
.Equals("Dynamic"))
{
// Create the DynamicConnectionshape.
newShape =
drawingPage.DropLinked(connectionMaster.set,
(randomLocation.NextDouble() * 10),
(randomLocation.NextDouble() * 10),
connectionsDataRecordset.ID,
thisRowID,
false);

}

if (((string)rowData.GetValue(4))
.Equals("Logical"))
{
newShape =
drawingPage.DropLinked(LogicalconnectionMaster,
(randomLocation.NextDouble() * 10),
(randomLocation.NextDouble() * 10),
connectionsDataRecordset.ID,
thisRowID,
false);

}
// Visio.Window conwin =
newShape.OpenSheetWindow();
// Set the Name value.
newShape.get_Cells("Prop._VisDM_Name").Formula
=
"\"" +
rowData.GetValue(nameColumnIndex).ToString() + "\"";


newShape.get_Cells("Prop._VisDM_ItemFrom").Formula = "\"" +
rowData.GetValue(fromColumnIndex).ToString() + "\"";

// Glue the connection to the Item shapes.
int shapeIndexFrom =
(int)_ItemShapeIndexMap[
(int)rowData.GetValue(fromColumnIndex)];
int shapeIndexTo =
(int)_ItemShapeIndexMap[
(int)rowData.GetValue(toColumnIndex)];
glueConnectionToItems(
drawingPage,newShape, shapeIndexFrom,
shapeIndexTo);


}

connectionsAdded = true;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}

return connectionsAdded;
}

Thanks
Shail
 
P

Paul Herber

Hi Paul,

Ca you tell me how can I do that because I am not getting any
setObjecttype option.

either set it manually in the shapesheet or
or use the CellsSrc method on section visSectionObject and cell
visLOFlags.
 
S

shailendrasingh823

either set it manually in the shapesheet or
or use the CellsSrc method on section visSectionObject and cell
visLOFlags.

--
Regards, Paul Herber, Sandrila Ltd.
Visio Utilities http://www.visio-utilities.sandrila.co.uk/- Hide quoted text -

- Show quoted text -

Hi Paul,

Thanks for ur response,

But still I am not clear How to do that,I tried but could not work
all.
Can you tell me how to do that with some code example.
I will be thankful for youu.

Thanks
Shail
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top