TurboCAD Forums

The Ultimate Resource for TurboCAD Knowledge

When posting a problem be sure to include which version you are using.  Give as much information as possible.  If the problem is with a specific file be sure to attache it to your post.

Adding a double line object - VC++
Read 4398 times
* June 30, 2009, 06:23:18 AM
I enclose here a sample code to add a double line object programmatically.
Hope this helps in giving and idea on what is the way TurboCAD works.
If needed, I can provide a small VC++ project


#import "C:\Program files\IMSI\TCWP12\Program\IMSIGX12.DLL" no_namespace rename ("Properties","TCADProperties") rename ("Property","TCADProperty") rename ("Selection","TCADSelection") rename ("View","TCADView")   rename ("Window","TCADWindow")
DrawDoubleLine(double xPos,double yPos,double x1Pos, double y1Pos,double offset, _bstr_t layer)
   VARIANT varMissing;
   varMissing.vt = VT_ERROR;
   varMissing.scode = DISP_E_PARAMNOTFOUND;

   VARIANT varGrType;
   varGrType.vt = VT_BSTR;
   varGrType.bstrVal = _bstr_t(_T("TCW25DblLine"));
   GraphicsPtr m_pGraph;
               IDrawingPtr m_IDraw;
                IApplicationPtr m_IApp;
IGraphicPtr pNewLine = NULL;
   VerticesPtr vtxsPtr = NULL;
   IVertexPtr vtx = NULL;
   VARIANT var1;

m_IApp = IApplicationPtr(__uuidof(XApplication),NULL, CLSCTX_INPROC_SERVER);
               m_pDrawings = m_IApp->GetDrawings();
   _bstr_t s = "TEst.dwg";
   m_IDraw = m_pDrawings->Open(s);
   m_pGraph = m_IDraw->GetGraphics();
   pNewLine = m_pGraph->Add (&varMissing, &varGrType, &varMissing, &varMissing, &varMissing, &varMissing);

   COleVariant x1 (xPos); COleVariant y1 (yPos); COleVariant z1 ((double) 0);
   COleVariant x2 (x1Pos); COleVariant y2 (y1Pos); COleVariant z2 ((double) 0);

   VARIANT varFalse;
   varFalse.vt = VT_BOOL;
   varFalse.boolVal = FALSE;
   varFalse.bVal = FALSE;

   TCADPropertiesPtr pProps = NULL;
   HRESULT hRes = pNewLine->get_TCADProperties (&pProps);
   TCADPropertyPtr pProp = NULL;
   COleVariant var = COleVariant(_T("$DLINEWID"));
   pProps->get_Item (&var, &pProp);
   COleVariant var1(offset);
   pProp->put_Value (0, &var1);

   var = COleVariant(_T("$DLINEALG"));
   pProps->get_Item (&var, &pProp);
   var1 = short(0);
   pProp->put_Value (0, &var1);
   vtxsPtr = pNewLine->Vertices;
   vtx = vtxsPtr->Add (&x1, &y1, &z1, &varFalse, &varFalse, &varFalse, &varFalse, &varFalse, &varFalse);
   vtx = vtxsPtr->Add (&x2, &y2, &z2, &varFalse, &varFalse, &varFalse, &varFalse, &varFalse, &varFalse);
   if (layer.length() > 0)
      COleVariant lay = layer;