Attempted to read or write protected memory. This is often an indication that ot

Attempted to read or write protected memory. This is often an indication that ot

Anonymous
Not applicable
1,048 Views
3 Replies
Message 1 of 4

Attempted to read or write protected memory. This is often an indication that ot

Anonymous
Not applicable
that's the error i get when i try to create a query.

the code is:
acad = GetObject(, "Autocad.Application.17")
acadmap =acad.ActiveDocument.Application.GetInterfaceObject("AutoCADMap.Application")
atdr = acadmap.Projects.Item(0).DrawingSet.Add("C:\stam\dwg\Sheboygan\Counties.dwg")
prj = acadmap.Projects.Item(0)
qry = prj.CurrQuery()
qry.Clear()
mainqrybr = qry.QueryBranch
qrylf = mainqrybr.Add(EClassId.kLocationCondition,EJoinOperator.kOperatorAnd)

who know what's that..
0 Likes
1,049 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
Hello Sir,
Were you able to get any resolution to your problem? I am facing the same issue. I am using Autodesk 2004. As soon as I try to create the qrylf, my application crashes. If you have the solution would be kind enough to share it. I would really appreciate your help.
I am attempting this through VB6.

Best Regards,
Raj
0 Likes
Message 3 of 4

Anonymous
Not applicable
Hi,

Could you solve the qrylf problem. If yes, please let me know how.

I am also facing the same problem.

Regards
0 Likes
Message 4 of 4

Anonymous
Not applicable
This may give you some ideas ...
{code}
public void getfloorplan(double[] box)
{
Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Database db = HostApplicationServices.WorkingDatabase;

ProjectModel prjModel = HostMapApplicationServices.Application.ActiveProject;
string current_projection = prjModel.Projection;
ProjectOptions prjOptions = prjModel.Options;
DrawingSet drawingset = prjModel.DrawingSet;

MapApplication mapApi = HostMapApplicationServices.Application;
Aliases aliases = mapApi.Aliases;
string The_Detailplan_alias = "FinalPathToDetailDWG";
string The_Detailplan = Get_("FinalPathToDetailDWG");
//Remove Alias
try
{
aliases.RemoveAlias(The_Detailplan_alias);
}
catch (MapException)
{
doc.Editor.WriteMessage("\nFailed to remove Detailplan alias ... probably OK.");
}
//Add Alias
try
{
aliases.AddAlias(The_Detailplan_alias, The_Detailplan);
}
catch (MapException)
{
doc.Editor.WriteMessage("\nFailed to add Detailplan alias. NOT good.");
}

drawingset.AttachDrawing(The_Detailplan_alias);

QueryModel qryModel = prjModel.CurQuery;
qryModel.Mode = Autodesk.Gis.Map.Constants.QueryType.QueryDraw;
qryModel.Clear();
// The root query object
QueryBranch qb_root = QueryBranch.Create();

// By location condition
LocationCondition locationcondition = new LocationCondition();
locationcondition.LocationType = Autodesk.Gis.Map.Constants.LocationType.LocationCrossing;
WindowBoundary windowboundary = new WindowBoundary(new Point3d(box[0], box[1], box[2]),
new Point3d(box[3], box[4], box[5]));
locationcondition.Boundary = windowboundary;
QueryBranch qblocation = QueryBranch.Create();
qblocation.AppendOperand(locationcondition);
// append to the root
qb_root.AppendOperand(qblocation);

// By Properties condition
PropertyCondition propertycondition = new PropertyCondition();
propertycondition.JoinOperator = Autodesk.Gis.Map.Constants.JoinOperator.OperatorAnd;
propertycondition.PropertyType = Autodesk.Gis.Map.Constants.PropertyType.Layer;
propertycondition.ConditionOperator = Autodesk.Gis.Map.Constants.ConditionOperator.ConditionEqual;

string The_DetailLayers = Get_("DetailLayers");
propertycondition.Value = The_DetailLayers;

// Make a branch
QueryBranch qbproperties = QueryBranch.Create();
qbproperties.AppendOperand(propertycondition);
// append it to the root
qb_root.AppendOperand(qbproperties);
// Construct it
qryModel.Define(qb_root);

ObjectIdCollection queried_floorplan_objs_collection = qryModel.Execute(drawingset);

// use the COM object to zoom
AcadApplication pApp;
pApp = (Autodesk.AutoCAD.Interop.AcadApplication)Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication;
pApp.ZoomExtents();

drawingset.DetachDrawing(The_Detailplan_alias);
}
{code}

r,
dennis