.NET

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

Hatch Problem!

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

*Expert Elite*
norman.yuan
Posts: 987
Registered: ‎04-27-2009
Message 2 of 4 (516 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 (511 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 (507 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!

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.