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!

33 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,

Mike Paramo said...

Hello Fernand!
i want to compile my application to AUtocad 2017 and Win 10 64 bits, i used VS 2017 and ObjectArx 2017 but when i load to Autocad say me it's not compatible...you can help me
thanks

Fernando Malard said...

Hello Mike,

AutoCAD 2017 requires ObjectARX 2017 and VC.NET 2015 (14.0)

VS2017 won't work (except if you have VS2015 installed and redirect the compilation engine toolset to 14.0).

Regards,

Mike Paramo said...

hello Fernando,

how can i debug my arx 64 bits app in vs 2017?

thanks in advanced

Fernando Malard said...

Mike,

If you are using VS2017, this sample won't debug.

Just as a reminder:

AutoCAD 2000,2000i and 2002: ObjectARX 2000 and VC++ 6.0;
AutoCAD 2004, 2005 and 2006: ObjectARX 2004 and VC.NET 2002 (7.0);
AutoCAD 2007, 2008 and 2009: ObjectARX 2007 and VC.NET 2005 (8.0);
AutoCAD 2010, 2011 and 2012: ObjectARX 2010 and VC.NET 2008 (9.0);
AutoCAD 2013 and 2014: ObjectARX 2013 and VC.NET 2010 (10.0);
AutoCAD 2015 and 2016: ObjectARX 2015 and VC.NET 2012 (11.0);
AutoCAD 2017: ObjectARX 2017 and VC.NET 2015 (14.0);
AutoCAD 2018: ObjectARX 2018 and VC.NET 2015 (14.0 - Update 3);

You still can use VS2017 to compile and build if you set the appropriate debug engine via Platform Toolset but it won't be able to debug in AutoCAD 2017.

Regards,

Mike Paramo said...

Hello Fernand:

Well, the problem is MSVSMON.EXE can´t start in VS2017 and VS2015 too...



Fernando Malard said...

Did this start after you install VS2017?
Have you tried to install all updates on both VS?

Check this out: https://stackoverflow.com/questions/19348309/visual-studio-debug-error-about-msvsmon-exe-not-appear-to-be-running

Regards,

Mike Paramo said...

Hello Fernand:

THis message appears when i run msvsmon.exe from its location:

msvsmon was unable to start a server named: 'User'. The following error ocurred: 0xc0000005
View msvsmon's help for more information.

Help me!

Fernando Malard said...

Sorry Mike, I don't know what could be happening.
Did you try to check Microsoft's discussion groups?
Maybe it is a VS thing and has nothing to do with AutoCAD.

Good luck.

Mike Paramo said...

Hello Fernand:

I want to compile my 64 bits arx project in VS 2015 to debug for Autocad 2017 but the compilation stop due an error TRack 0005: mt.exe do not found...
what can i do?

Thanks in advance

Fernando Malard said...

Mike, it seems you have an issue with your VS2015 installation.
What I would recommend:

- First try to install all VS2015 updates
- It this doesn't solve this issue, take a look at some procedures mentioned in this thread: https://social.msdn.microsoft.com/Forums/SECURITY/en-US/aa5ef8b2-68e4-48a2-8e39-24c73dc377cf/visual-studio-2015-professional-with-update-1-missing-mtexe?forum=vssetup

Regards,

Mike Paramo said...

Good norning Fernand!

i would like to know if i can compile and debug a 64 bits arx app if VS 2015 is a 32 bits software and my pc and Windows 10 are 64 bits.

So long


Fernando Malard said...

Mike,

No, Autodesk does have a specific 32/64-bit install so you need to have AutoCAD 64-bit running in Windows 64-bit. Same applies to 32-bit.

You can compile and build a 32-bit code in Windows 64-bit though. Visual Studio 2015 is indeed a 32-bit application but its compiler/builder can process 64-bit files.

What I would recommend is to work with Virtual machines like VMWare so you can prepare your testing machines with appropriate AutoCAD and Windows versions.

So, in a nutshell:

1) Developer machine: Windows-64, Visual Studio 2015 and AutoCAD 64-bit

2) 32-bit Testing machine: Windows-32 and AutoCAD 32-bit (you won't need VS in this machine except if you have a really severe issue in 32-bit only that requires you to debug your code in 32-bit). Even though, you can setup VS for a remote debugging from your Developer machine accessing the Testing machine.

3) 64-bit Testing machine: Optional, if you think you can do the 64-bit testing in your Developer machine, that's fine.

Hope this helps.

Mike Paramo said...

Well, I suspect that the ASP NET user has something to do with it, that when Windows 10 asks me for an account, it did not do it before. Put the message: Another user and in the Windows accounts an ASP NET user appears, I believe that he takes my account as if he were a remote user and tries to start the remote debugger in VS 2015 when this is not necessary ...
What do you think about this?

regards

Fernando Malard said...

Hi Mike,

I don't know what is going on.
Did you try to uninstall VS, reboot and reinstall it?
Maybe this will fix this issue.

Anyway, it is a trial and error process.
Try to also post on Microsoft's VS discussion groups...you can get better insights there.

Regards,