Quantcast
Channel: MicroStation Programming - Forum - Recent Threads
Viewing all articles
Browse latest Browse all 1677

Re: [V8i C++] mdlAssoc_createOrigin()

$
0
0

Bruce Reeves SRNS:
I'm looking at mdlAssoc_createOrigin() in an attempt to create an association between a line and a cell

I looked through my dusty storeroom of MDL snippets to see if I could find anything that might help you. There are a couple of fragments, authored by — Brien Bastings …

/*
Here's an example adding an association created from the current snap point,
also, take a look at the mdlAssoc_create functions, in particular, you might
want to use mdlAssoc_createKeypoint in your application. HTH

> This sounds like a job for the Dependency Manager.

> There are no examples delivered with MicroStation, but if you ask Bentley
> support they may be able to supply something. 'BoxDependency' springs to
> mind.

>> Anybody know the way to associate cells on line vertex? I would like
>>to have this type of association to update the line when we move a
>>cell describing one of its vertex or moving a cell when a vertex is moved.


Given an existing element descriptor for a cell, cellEdP:
*/
AssocPoint assocPt;

// Get assoc point from current snap if user has cell associations enabled...
if (mdlAssoc_getCurrent (&assocPt, NULL, 0, ~ASSOC_CREATE_MASK_CELLS))
{
  MSElement cellHdrElm;
  
  mdlElement_memcpy (&cellHdrElm, &cellEdP->el);
  
  // Insert cell origin assoc point dependency...
  if (SUCCESS == mdlAssoc_insertPoint (&cellHdrElm, &assocPt, 0, 1))
  {
    DPoint3d origin;
    
    // This isn't strictly necessary...will be done when dependency callback is invoked...
    // also we could have used optional location point returned from
    // mdlAssoc_getCurrent instead of evaluating assoc point here, this makes
    // more sense if using one of the mdlAssoc_create functions...
    if (SUCCESS == mdlAssoc_getPoint (&origin, &assocPt, modelRef))
    {
      if (elm.hdr.dhdr.props.b.is3d)
      {
        cellHdrElm.cell_3d.origin = origin;
      }
      else
      {
        cellHdrElm.cell_2d.origin.x = origin.x;
        cellHdrElm.cell_2d.origin.y = origin.y;
      }
    }
    
    mdlElmdscr_replaceElement (&cellEdP, &cellHdrElm);
  } }
Private void addAssociativeCellToLineInActiveModel
(
ElementID lineElmId
)
{
  MSElement tmpElm;
  MSElementDescr *cellEdP;
  AssocPoint assoc;
  DPoint3d origin;
  TextSizeParam textSize;
  
  // Create your favorite type of assoc point; we'll use line's origin here...
  mdlAssoc_createKeypoint (&assoc, 0, 0, 0, 2, NULL, lineElmId);
  mdlAssoc_getPoint (&origin, &assoc, ACTIVEMODEL);
  
  // Create new orphan cell header...origin is evaluated assoc point location...
  mdlCell_create (&tmpElm, NULL, &origin, FALSE);
  mdlAssoc_insertPoint (&tmpElm, &assoc, 0, 1);
  
  // Create a new element descriptor for the cell...
  mdlElmdscr_new (&cellEdP, NULL, &tmpElm);
  
  // Create the text element...origin same as cell's...add it to cell descriptor...
  memset (&textSize, 0, sizeof (textSize));
  textSize.mode = TXT_BY_TEXT_SIZE;
  textSize.size.width = 10000.0;
  textSize.size.height = 10000.0;
  textSize.aspectRatio = -1;
  
  mdlText_create (&tmpElm, NULL, "H", &origin, &textSize, NULL, NULL, NULL);
  mdlElmdscr_appendElement (cellEdP, &tmpElm);
  mdlCell_setRange (cellEdP, ACTIVEMODEL);
  
  // Add cell to file...
  mdlElmdscr_add (cellEdP);
  mdlElmdscr_display (cellEdP, ACTIVEMODEL, NORMALDRAW);
  mdlElmdscr_freeAll (&cellEdP);
}

There's also the BoxDependency example, which you may be able to get from Mark Anderson.

Regards, Jon Summers
LA Solutions


Viewing all articles
Browse latest Browse all 1677

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>