TheSwamp

Code Red => .NET => Topic started by: latour_g on November 20, 2019, 04:53:46 PM

Title: Entity jig preview not working for annotative block
Post by: latour_g on November 20, 2019, 04:53:46 PM
Hi,

the title says it all, I'm using Entity Jig when inserting block to see the block preview.  It work fine except for annotative block, there is no preview showing.  Is there something that need to be done for annotative block ?

Here is a snippet of my code :

Code - C#: [Select]
  1. Point3d pt = new Point3d(0, 0, 0);
  2. BlockReference br = new BlockReference(pt, bt[BlkName]);
  3. br.TransformBy(ed.CurrentUserCoordinateSystem);
  4. br.ScaleFactors = (bAnno) ? new Scale3d(1, 1, 1) : new Scale3d(nScale, nScale, nScale);
  5.  
  6. if (bAnno)
  7. {
  8.        BlockTableRecord btr2 = (BlockTableRecord)tr.GetObject(br.BlockTableRecord, OpenMode.ForWrite);
  9.        btr2.Annotative = AnnotativeStates.True;
  10.        ObjectContextManager ocm = db.ObjectContextManager;
  11.        ObjectContextCollection occ = ocm.GetContextCollection("ACDB_ANNOTATIONSCALES");
  12.        ObjectContexts.AddContext(btr2, occ.CurrentContext);
  13. }
  14.  
  15. InsertJig entJig = new InsertJig(br);
  16. Utils.SetFocusToDwgView();
  17. PromptResult pr = ed.Drag(entJig);
  18. string c = pr.StringResult;

Thank you !
Title: Re: Entity jig preview not working for annotative block
Post by: Hanauer on November 21, 2019, 07:51:33 AM
For me jig with block annotative works.
Have you added the block reference in the current space (currentSpace.AppendEntity(br);)?
Where you added the current annotative scale to the block reference (br.AddContext(occ.CurrentContext);)?
Try replace ObjectContexts.AddContext(btr2, occ.CurrentContext); with br.AddContext(occ.CurrentContext);
Example https://www.keanw.com/2015/05/jigging-an-autocad-block-with-attributes-using-net-redux.html (https://www.keanw.com/2015/05/jigging-an-autocad-block-with-attributes-using-net-redux.html)
Code: [Select]
var currentSpace = (BlockTableRecord)tr.GetObject(m_db.CurrentSpaceId, OpenMode.ForWrite);
br.TransformBy(m_doc.Editor.CurrentUserCoordinateSystem);
currentSpace.AppendEntity(br);
tr.AddNewlyCreatedDBObject(br, true);

if (btr.Annotative == AnnotativeStates.True)
{
     ObjectContextManager ocm = m_db.ObjectContextManager;
     ObjectContextCollection occ = ocm.GetContextCollection("ACDB_ANNOTATIONSCALES");
     br.AddContext(occ.CurrentContext);
}
else
{
      br.ScaleFactors = new Scale3d(br.UnitFactor);
 }
Title: Re: Entity jig preview not working for annotative block
Post by: latour_g on November 21, 2019, 09:59:50 AM
It's working now by replacing ObjectContexts.AddContext(btr2, occ.CurrentContext); with br.AddContext(occ.CurrentContext);

Thank you really much !