Saturday, June 27, 2015

AU2015 Classes







My Autodesk University 2015 classes were accepted.

SD9661: AutoCAD, JavaScript, and the Cloud

SD9660: Creating AutoCAD Cross-Platform Plug-ins

SD9662: Creating Professional Plug-ins for Autodesk Exchange Store

GEN9663: From AutoCAD I/O to View & Data

Hope to meet you there!

19 comments :

Anonymous said...

Hello Fernando you know of an official training center for ObjectARX or any online course that covers in depth the development of applications for AutoCAD. Regards.

Fernando Malard said...

Hello,

Autodesk does provide some training sessions through out the year.
You can also access one of their introductory class using ObjectARX.NET here:

http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=18162650

As you may already know, Autodesk University is also another great resource of information.

Regards.

Anonymous said...

Hello Fernando,
I'm unable to rotate an entity through center( I need to enable OSMODE through coding).
Here is my code below:

void cmdRectangle()
{
ads_name en;
ads_point pt;

//Prompt for selection
if (acedEntSel( _T("\nSelect an entity: "),en,pt)==RTNORM)
{
AcDbObjectId eId =AcDbObjectId::kNull;
//Get the ObjectId from ads_name
acdbGetObjectId(eId, en);
AcDbEntity* pEnt = NULL;
AcGeMatrix3d matrix;
AcGePoint3d point1;
//AcGePoint3d point;
AcGeVector3d vec(0.0,0.0,1.0);
point1.set(0,0,0);
matrix.setToRotation(80*3.141/180,vec,point1);
if(acdbOpenObject((AcDbObject*&)pEnt,eId,AcDb::kForWrite)== Acad::eOk)
{
pEnt->transformBy(matrix);
pEnt->close();
}
}
else
acutPrintf(_T("\nCommand aborted"));
}
Can you please suggest.
Thank you.

Fernando Malard said...

Hello,

You can use acedSetVar() and acedGetVar() to set and retrieve AutoCAD variables.
I would recommend you to first store the current OSMODE value to restore it after your command is finished so you don't mess with user's current configuration.

Regards,

Esaias Pech said...

Hi Fernando, I wonder if you know, what version of Visual Studio is required for ObjectARX 2016?

Fernando Malard said...

Hi Esaias,

You will need Visual Studio 2012/2013 to compile the code.
If you use 2013 make sure you set the Platform Toolset to 11.0 which is the VS2012 release number.
To be able to use the Platform Toolset you will also need to have VS2012 installed at the same machine you have VS2013.

I haven't tested VS2015 but I believe, through Platform Toolset, it should work as well.

Please find more detailed information here: http://arxdummies.blogspot.com.br/2005/01/requirements.html

Regards,

Rahul said...

Hi Fernando,

I need to create ConstrainedCircle. Can you suggest me what changes I have make on my normal circle to make it constrainedcircle.

here is my function

createCircle()
{
AcGePoint3d center(9.0, 3.0, 0.0);
AcGeVector3d normal(0.0, 0.0, 1.0);
AcDbCircle *pCirc = new AcDbCircle(center, normal, 2.0);
AcDbBlockTable *pBlockTable;
acdbHostApplicationServices()->workingDatabase()
->getSymbolTable(pBlockTable, AcDb::kForRead);
AcDbBlockTableRecord *pBlockTableRecord;
pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord,
AcDb::kForWrite);
pBlockTable->close();
AcDbObjectId circleId;
pBlockTableRecord->appendAcDbEntity(circleId, pCirc);
pBlockTableRecord->close();
pCirc->close();

Regards,


Fernando Malard said...

Hi Rahul,

It is not a simple thing to do.
I would recommend a detailed read through AcDbAssocAction class on ObjectARX documentation.
There isn't any simple example on how to do it neither do I have something ready to share.

I have found a code sample from 2011 but it could still be valid with latest ObjectARX SDK:

http://ohno-iamanerd.blogspot.com.br/2011/01/developing-associative-features-in.html

Hope it helps.

Rahul said...

thanks fernando.

very useful information but actually I am working on BricsCAD and I want to constrain the raidus of 3d entity. I am not able to find the API for doing the same, do you know the BricsCAD API for implementing the 3D constraints or any other blog that may help me out

Regards,

Fernando Malard said...

Hi Rahul,

I see, the BricsCAD SDK is always behind ObjectARX.
One thing you could do is to mimic the constraints behaviour by attaching an Entity Reactor to the circles you want to monitor. The reactor would notify you whenever some modifications are applied to the entities your are monitoring.

Take a further look at the Reactors chapter and see if it could help you.
Note that the reactor functionality is available only when you have your app up and running in contrast with native AutoCAD constraints.

Regards.

Anonymous said...

Hi Fernando,

How can we get a point on 3dsolid? Say if I want to get a point x,y distance away (on the upper surface) from the top corner of a 3dsolid plate. could you give some hint

Regards,

Fernando Malard said...

Hi,

You can trace a small line from this point towards the direction you want to find the solid.
Then, using intersectWith() method you can extend this line to the direction its vector points.

This method will return an array of points intersecting the solid so then you get each of those points and calculate the distance from the original point. The nearest point is the one you want.

Regards,

Anonymous said...

Hi,

I have created one 3D solid, by making polyline, then creating region and finally extruding it. But below my solid one region is also getting created which I dont want. If I select my solid and delete it, the region gets remained. How can I delete the region thats existing below my solid?

Fernando Malard said...

For entities you already added to database you need their AcDbObjectId, open them for Write and call erase() followed by a close() method call.

For non database resident entities you can simply delete their pointer.

So:

Database resident: ObjectId > Open for write > erase() > close()
Non database resident: entity pointer > delete

Regards,

Anonymous said...

Hi fernando,

I was wondering if it is possible to zoom an external database file. Actually I am cloning some entities from my current file and storing them into other file but the size of the entities remains very small and when I open that file I need to manually zoom it.

I want to zoom in the entities in my current file and then save them in separate files. is it possible using objectarx?

thanks

Fernando Malard said...

Hi,

The external database will be a new file thus will have its own ViewportTable. I never tried to manipulate the AcDbViewportTable on an external database but I believe you can set the "*Active" viewport settings programmatically without having this database active and current.

That said, even setting its parameters accordingly to your selection set extents (take a look at AcDbExtents class), you will need to call acedVportTableRecords2Vports() method which will force a regeneration of the active drawing. If your external database is not opened and visible this call won't probably do anything. One hope lies into the possibility AutoCAD does that everytime it opens a DWG so if you set the viewport parameters on your external DWG next time it opens should show the view at the coordinates you specified.

Here is an old code that performs a zoom extents into the active/current DWG:
=========================================================



Acad::ErrorStatus mEs;
AcDbDatabase* pDb = acdbHostApplicationServices()->workingDatabase();
mEs = acedVports2VportTableRecords();
AcDbViewportTable *pVpT = NULL;
AcDbViewportTableRecord *pActVp = NULL;

mEs = pDb->getViewportTable(pVpT,AcDb::kForRead);
mEs = pVpT->getAt(_T("*Active"),pActVp,AcDb::kForWrite);
pVpT->close();

pDb->updateExt(false);

double mHeight = 1.0;
AcGePoint2d mCentPt;

double mScrRatio = 1.0;
mScrRatio = (pActVp->width() / pActVp->height());

double mWidth = 1.0;

// If your drawing contains more entities than those you want to zoom into you will need to calculate the desired entities extents.
AcGePoint3d mMaxExt = pDb->extmax(), mMinExt = pDb->extmin();

AcGeMatrix3d matWCS2DCS;
matWCS2DCS.setToPlaneToWorld(pActVp->viewDirection());
matWCS2DCS = AcGeMatrix3d::translation(pActVp->target() - AcGePoint3d::kOrigin) * matWCS2DCS;
matWCS2DCS = AcGeMatrix3d::rotation(-pActVp->viewTwist(), pActVp->viewDirection(),pActVp->target()) * matWCS2DCS;
matWCS2DCS = matWCS2DCS.inverse();

AcDbExtents mExtents(pDb->extmin(),pDb->extmax());
mExtents.transformBy(matWCS2DCS);

mWidth = (mExtents.maxPoint().x - mExtents.minPoint().x);
mHeight = (mExtents.maxPoint().y - mExtents.minPoint().y);
mCentPt.x = (mExtents.maxPoint().x + mExtents.minPoint().x)*0.5;
mCentPt.y = (mExtents.maxPoint().y + mExtents.minPoint().y)*0.5;

if (mWidth > (mHeight * mScrRatio))
mHeight = mWidth / mScrRatio;

pActVp->setHeight(mHeight);
pActVp->setWidth((mHeight * mScrRatio));
pActVp->setCenterPoint(mCentPt);

pActVp->close();

// This won't probably work if your external database isn't active/current, so maybe you don't need to call it.
mEs = acedVportTableRecords2Vports();



=========================================================

Hope this helps.

Anonymous said...

Thanks a lot fernando.. :)

Anonymous said...


Boa noite Fernando
pode me ajuda com esses erros... naõ consigo sair do inicio... obrigado

Gravidade Código Descrição Projeto Arquivo Linha Estado de supressão
Aviso LNK4099 PDB 'rxapi.pdb' was not found with 'rxapi.lib(libinit.obj)' or at 'd:\documentos\visual studio 2015\Projects\Exercicio2\x64\Release\rxapi.pdb'; linking object as if no debug info AuCustomObjects d:\documentos\visual studio 2015\Projects\Exercicio2\AuCustomObjects\rxapi.lib(libinit.obj) 1


Gravidade Código Descrição Projeto Arquivo Linha Estado de supressão
Erro LNK2001 unresolved external symbol "public: __cdecl AuPolyline::AuPolyline(void)" (??0AuPolyline@@QEAA@XZ) AuUserInterface d:\documentos\visual studio 2015\Projects\Exercicio2\AuUserInterface\acrxEntryPoint.obj 1

Fernando Malard said...

Olá,

Percebi que está utilizando o Visual Studio 2015 que somente permite projetos compilados com o ObjectARX 2017 e AutoCAD 2017. Se você está compilando seu projeto com outra versão do ObjectARX, não irá funcionar.

Lembrando que:

AutoCAD 2013, 2014 -> Visual Studio 2008 + ObjectARX 2013
AutoCAD 2015 e 216 -> Visual Studio 2010 + ObjectARX 2015
AutoCAD 2017 -> Visual Studio 2015 + ObjectARX 2017

Certifique-se ainda que o projeto ARX seja dependente do DBX para que sempre compile o DBX primeiro e importe suas bibliotecas.

Espero que ajude.

Abraços,