Hello, i have a problem with hatch objects, I cant set an acadCircle with AppendInnerLoop. This is my code in c#:
public void DibujarCirculos(object centro, double radio)
{
AcadCircle circleobj;
AcadHatch hatchObj;
circleobj = doc.ModelSpace.AddCircle(centro, radio);
circleobj.Update();
string patternName = "Solid";
int PatternType = 0;
bool bAssociativity = true;
hatchObj = doc.ModelSpace.AddHatch(PatternType, patternName, bAssociativity);
hatchObj.AppendInnerLoop(circleobj); //-----------------> Error !!!!!
hatchObj.Update();
hatchObj.Evaluate();
}
Thanks!!!!
Solved! Go to Solution.
Solved by norman.yuan. Go to Solution.
So, you are doing COM API development, aren't you?
There are at least 2 errors:
1. You cannot add an inner loop before a CLOSED outer loop is created. That is, you must call AcadHatch.AppendOuterLoop() method first. This is clearly documented in VBA help document, quoted here:
<QUOTE>
Remarks
After the Hatch object has been created using the AddHatch method, add the outer loop using AppendOuterLoop. The outer loop must be closed and must be created before any inner loops can be added.
</QUOTE>
2. AppendOuter/InnerLoop() method takes an object array as input parameter, while you pass it a single object.
The code should be:
//Outer loop
objecct[] outloop=new object[<number of entities that forms a closed loop>];
//create each entity that is part of the outer loop and assign it
//to the object array's element
//Inner loop (only one entity - a circle)
objetc[] inloop=new object[1];
AcadCircle circleobj=doc.ModelSpace.Add(...);
inloop[0]=circleobj
...
...
hatchObj.AppendOuterLoop(outloop);
hatchobj.AppendInnerLoop(inloop);
...
...
Norman Yuan
In the AppendInnerLoop I cant put a simple object array, only acept AcadObject array but if I use this I cant set it with circleObj:
AcadObject[] inloop = new AcadObject[1];
AcadCircle circleobj=doc.ModelSpace.Add(...);
inloop[0]=circleobj; ---------------------------> ERROR
(An instance of type 'Autodesk.AutoCAD.Interop.Common.AcadCircle' can not be assigned to a variable of type 'Autodesk.AutoCAD.Common.AcadObject')
In all examples with VB. Net they use "Set inloop[0] = circleobj" everything work fine, but in c# not... 😞
...
...
//Inner loop (only one entity - a circle)
objetc[] inloop=new object[1];
AcadCircle circleobj=doc.ModelSpace.Add(...);
inloop[0]=circleobj
...
...
hatchObj.AppendOuterLoop(outloop);
hatchobj.AppendInnerLoop(inloop);
I could do it!!!!!!!!!!!!!
with Object[] inloop = new AcadObject[1];
Thank!