.NET

Reply
Member
m3nt0r
Posts: 3
Registered: ‎06-28-2011
Message 1 of 4 (557 Views)
Accepted Solution

Hatch Problem!

557 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*
norman.yuan
Posts: 1,064
Registered: ‎04-27-2009
Message 2 of 4 (541 Views)

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
m3nt0r
Posts: 3
Registered: ‎06-28-2011
Message 3 of 4 (536 Views)

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
m3nt0r
Posts: 3
Registered: ‎06-28-2011
Message 4 of 4 (532 Views)

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
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.