Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 919
  • Last Modified:

ObjectARX - autocad programing

  ***Autocadprograming - ObjectARX - C++***
Hallo,
Woundering if any one knows how to set insertion point for a AcDb3dsolid (box), by default it is 0,0,0... I whant it to be user defined, but can´t find member function setting koordinats..

/Daniel
0
tankthall
Asked:
tankthall
1 Solution
 
OMC2000Commented:
solids are always created with centroid (0,0,0) so you must translate it to the place you want it to be.

void
EntMakeDbox::make3dSolid()
{
    acutPrintf(_T("\nTesting make of AcDb3dSolid (BOX) ..."));

    ArxDbgUiPrPoint prCentroid(_T("Centroid"), NULL);
    ArxDbgUiPrDist prXLen(_T("X-length"), NULL, ArxDbgUiPrDist::kNoNegNoZero);
    ArxDbgUiPrDist prYLen(_T("Y-length"), NULL, ArxDbgUiPrDist::kNoNegNoZero);
    ArxDbgUiPrDist prZLen(_T("Z-length"), NULL, ArxDbgUiPrDist::kNoNegNoZero);

    if ((prCentroid.go() != ArxDbgUiPrBase::kOk) ||
        (prXLen.go() != ArxDbgUiPrBase::kOk) ||
        (prYLen.go() != ArxDbgUiPrBase::kOk) ||
        (prZLen.go() != ArxDbgUiPrBase::kOk))
        return;

    AcDb3dSolid* solid = new AcDb3dSolid;
    Acad::ErrorStatus es = solid->createBox(prXLen.value(), prYLen.value(), prZLen.value());
    if (es == Acad::eOk) {
            // solids are always created with centroid (0,0,0)
            // so you must translate it to the place you want it
            // to be.
        AcGeMatrix3d mat;
        mat.setTranslation(prCentroid.value().asVector());
        solid->transformBy(mat);

        solid->setDatabaseDefaults();
        ArxDbgUtils::transformToWcs(solid, acdbHostApplicationServices()->workingDatabase());        // could combine with above xform to be optimal
        ArxDbgUtils::addToCurrentSpaceAndClose(solid);
    }
}
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now