.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Hatch Problem!

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
m3nt0r
1368 Views, 3 Replies

Hatch Problem!

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

3 REPLIES 3
Message 2 of 4
norman.yuan
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);

...

...

 

Norman Yuan

Drive CAD With Code

EESignature

Message 3 of 4
m3nt0r
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... 😞

 

...

...

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

 

 

Message 4 of 4
m3nt0r
in reply to: norman.yuan

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

with Object[] inloop = new AcadObject[1]; Smiley Tongue

 

Thank!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost