Skip to main content
1-Visitor
October 5, 2021
Solved

Create Diameter Dimension VB API

  • October 5, 2021
  • 1 reply
  • 1741 views

Hi Everyone,

How do I create a diameter dimension using the free VB API (I'm using C#)? Additionally, the selection must be programmatic. I'm selecting an edge entity, using empty dimension senses, and no orientation hint. I know everything aside from orientation is working because it successfully creates a radius dimension (instead of diameter). See code snippet below.

Feels like I'm just missing something basic - any and all help greatly appreciated!

Thank you,
-Ben

 

 

IpfcView2D view = dwgModel2D.GetViewByName(viewName);
IpfcModel viewModel = view.GetModel();
IpfcModelItemOwner modelItemOwner = (IpfcModelItemOwner)viewModel;

IpfcModelItem entity1 = modelItemOwner.GetItemById((int)entityType1, entityID1);

CpfcSelections sels = new CpfcSelections();
IpfcSelection sel1 = new CMpfcSelect().CreateModelItemSelection(entity1, null);
sel1.set_SelView2D(view);
sels.Set(0, sel1);

CpfcDimensionSenses senses = new CpfcDimensionSenses();
senses.Set(0, sense1);
senses.Set(1, sense2);

CpfcVector2D vec = new CpfcVector2D();
vec.Set(0, xLoc); 
vec.Set(1, yLoc);

IpfcDrawingDimCreateInstructions someDim = new CCpfcDrawingDimCreateInstructions().Create(sels, senses, vec, (int)hint);
 
IpfcDimension2D newDim = dwgModel2D.CreateDrawingDimension(someDim);

 

 

Best answer by BD_9799497

Hi Everyone,

Solved my own issue here - to create a diameter dimension instead of a radius dimension, you just need to select the same entity twice (along with a little bit of this: CCpfcEmptyDimensionSense().Create() and a little bit of that: EpfcOrientationHint.EpfcORIENTHINT_NONE).

 

Hope this helps someone else!

 

-Ben

1 reply

BD_97994971-VisitorAuthorAnswer
1-Visitor
October 6, 2021

Hi Everyone,

Solved my own issue here - to create a diameter dimension instead of a radius dimension, you just need to select the same entity twice (along with a little bit of this: CCpfcEmptyDimensionSense().Create() and a little bit of that: EpfcOrientationHint.EpfcORIENTHINT_NONE).

 

Hope this helps someone else!

 

-Ben