Author Topic: Create an associative hatch using C#  (Read 2993 times)

0 Members and 1 Guest are viewing this topic.

ahlzl

  • Guest
Create an associative hatch using C#
« on: February 23, 2009, 08:12:47 AM »
You can create an associative hatch with the help of ARX:  http://www.theswamp.org/index.php?topic=24025.msg290732#msg290732
But without ARX,how to create an associative hatch using C#?
The following post gives you the answer:
http://www.objectarx.net/bbs/viewthread.php?tid=2883&extra=page%3D1

Bryco

  • Water Moccasin
  • Posts: 1883
Re: Create an associative hatch using C#
« Reply #1 on: February 24, 2009, 05:16:20 PM »
It must be a  trick question but
Code: [Select]
public Hatch HatchPline(ObjectId id)
        {
            Database db=HostApplicationServices.WorkingDatabase;
            Hatch h = new Hatch();
            ObjectIdCollection hs = new ObjectIdCollection();
            hs.Add(id);
            using(Transaction tr=db.TransactionManager.StartTransaction())
            {
                Polyline p=tr.GetObject(id,OpenMode.ForRead) as Polyline;
                h.SetDatabaseDefaults();
                h.Elevation=p.Elevation;
                h.Normal = p.Normal;
                h.PatternScale = 1;
                h.SetHatchPattern(HatchPatternType.PreDefined,"ANSI31");       
            }
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                BlockTableRecord Cspace = tr.GetObject
                    (db.CurrentSpaceId, OpenMode.ForWrite) as BlockTableRecord;
                Cspace.AppendEntity(h);               
                tr.AddNewlyCreatedDBObject(h, true);
                h.Associative = true;
                h.AppendLoop(HatchLoopTypes.External, hs);
                tr.Commit();             
            }
            return h;
         
        }

This makes associative hatch

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2132
  • class keyThumper<T>:ILazy<T>
Re: Create an associative hatch using C#
« Reply #2 on: February 24, 2009, 06:46:53 PM »

I thought I'd posted one as well, but couldn't find it, so may have been dreaming    :|
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.