.NET

Reply
Member
3 Posts
0 Kudos
Registered: ‎06-28-2011
Post 1 of 4
Accepted Solution

Hatch Problem!

563 Views, 3 Replies
06-28-2011 07:21 AM

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!!!!

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);

...

...

 

*Expert Elite*
1,088 Posts
217 Kudos
Registered: ‎04-27-2009
Post 2 of 4

Re: Hatch Problem!

06-28-2011 09:07 AM in reply to: m3nt0r

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);

...

...

 

Member
3 Posts
0 Kudos
Registered: ‎06-28-2011
Post 3 of 4

Re: Hatch Problem!

06-28-2011 10:11 AM in reply to: 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... :smileysad:

 



...

...

//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); 

 

 



Member
3 Posts
0 Kudos
Registered: ‎06-28-2011
Post 4 of 4

Re: Hatch Problem!

06-28-2011 10:30 AM in reply to: norman.yuan

I could do it!!!!!!!!!!!!!

with Object[] inloop = new AcadObject[1]; :smileytongue:

 

Thank!

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!