Tuesday, April 19, 2016

I’m going to be speaking at Forge DevCon 2016!

Autodesk has asked me to speak at their first-ever Forge Developers Conference (DevCon) to be held June 15-16 in San Francisco. DevCon is an immersive, high-level gathering of developers, innovators, and startups in the AEC, product design, and manufacturing space who are building next generation apps on the cloud.

If you are building a business leveraging the cloud, you really need to come to this conference!
DevCon is no ordinary conference – you’ll get hands-on with tools to help you create new service offerings, solutions and integrations for a cloud-connected product-development ecosystem; meet face-to-face with the largest community of developers in design and engineering from around the world; and learn best practices from industry experts and engineers utilizing and developing the Forge Platform.

If you’d like to join me at the conference, use this SPEAKER FRIENDS AND FAMILY CODE (SpkrFriendofcdesk) and receive 30% off of Early Bird & General Admission tickets.

For more information about the conference, check out the DevCon website.

Tuesday, August 18, 2015

Find all AcDbLine Intersections

Hello,

This question came from Sandhya who asked how to find all line intersections into a drawing.
In this case, we will consider only intersections between AcDbLine entities.

First we need to prepare our CMap structure to be able to handle AcGePoint3d as the map key. The idea is to group all Lines passing through each intersection point.

CMap does not support AcGePoint3d because it does not know how to Hash it and also how to compare it as a key. To allow that we will need to define both HasKey and CompareElements templates as follows:

// These are template classes to allow AcGePoint3d do be used as a Key do CMap class
const double _dTol = 0.0001;

template<> UINT AFXAPI HashKey<AcGePoint3d> (AcGePoint3d key)
{
CString sPoint;
sPoint.Format(_T("%f,%f,%f"),key.x, key.y ,key.z);

UINT iHash = (NULL == &key) ? 0 : HashKey((LPCSTR)sPoint.GetBuffer());
return iHash;
}

template<> BOOL AFXAPI CompareElements<AcGePoint3d, AcGePoint3d> 
     (const AcGePoint3d* pElement1, const AcGePoint3d* pElement2)
{
if ((pElement1 == NULL) || (pElement2 == NULL))
return false;
AcGeTol gTol;
gTol.setEqualPoint(_dTol); // Point comparison tolerance
return (pElement1->isEqualTo(*pElement2,gTol));
}

Next, we will collect the AcDbLine entities in ModelSpace:

// Collect lines from ModelSpace
Acad::ErrorStatus es;
AcDbDatabase *pDb = acdbHostApplicationServices()->workingDatabase();
AcDbBlockTableRecordPointer pBTR(acdbSymUtil()->blockModelSpaceId(pDb),AcDb::kForWrite);

AcDbBlockTableRecordIterator *pIter = NULL;
pBTR->newIterator(pIter, true);
AcDbObjectIdArray arrLines;

while(!pIter->done())
{
AcDbEntity *pEnt = NULL;
es = pIter->getEntity(pEnt, AcDb::kForRead);
if (es == Acad::eOk)
{
if (pEnt->isKindOf(AcDbLine::desc()))
arrLines.append(pEnt->objectId());

pEnt->close();
}

pIter->step(true);
}
delete pIter;
pIter = NULL;

if (arrLines.length() == 0)
{
acutPrintf(_T("There are no lines in Model Space!\n"));
return;
}
else
{
acutPrintf(_T("We've found %d lines in Model Space!\nChecking intersection with tolerance %f...\n"), 
arrLines.length(), _dTol);
}

Ok, with the lines collected we will then build our CMap with the information we need:

// Process lines in pairs
CMap<AcGePoint3d,AcGePoint3d,AcDbObjectIdArray,AcDbObjectIdArray&> mapLines;

acdbTransactionManager->startTransaction();
for (int i=0; i<arrLines.length()-1; i++)
{
AcDbLine* pLineA = NULL;
if (acdbTransactionManager->getObject((AcDbObject*&)pLineA,arrLines[i], AcDb::kForRead) == Acad::eOk)
{
for (int j=i+1; j<arrLines.length(); j++)
{
AcDbLine* pLineB = NULL;
if (acdbTransactionManager->getObject((AcDbObject*&)pLineB,arrLines[j], AcDb::kForRead) == Acad::eOk)
{
AcGePoint3dArray arrPts;
if (pLineA->intersectWith(pLineB,AcDb::kOnBothOperands,arrPts) == Acad::eOk)
{
if (arrPts.length() > 0)
{
for (int p=0; p<arrPts.length(); p++)
{
AcDbObjectIdArray arrExist;
if (mapLines.Lookup(arrPts[p],arrExist) == TRUE)
{
// Existing point...
if (arrExist.contains(pLineA->objectId()) == false)
mapLines[arrPts[p]].append(pLineA->objectId());

if (arrExist.contains(pLineB->objectId()) == false)
mapLines[arrPts[p]].append(pLineB->objectId());
}
else
{
// New point...
AcDbObjectIdArray arrNewEnts;
arrNewEnts.append(pLineA->objectId());
arrNewEnts.append(pLineB->objectId());
mapLines.SetAt(arrPts[p],arrNewEnts);
}
}
}
}
}
}
}
}

acdbTransactionManager->endTransaction();

To demonstrate the use of this information, we then use our CMap data to create AcDbPoint entities on ModeSpace and also print a small report at the command prompt:

// Just as demonstration, walk through points and add an AcDbPoint entity to ModelSpace then print the info
POSITION pos = mapLines.GetStartPosition();
while (pos)
{
AcGePoint3d ptKey(0,0,0);
AcDbObjectIdArray arrEnts;
mapLines.GetNextAssoc(pos,ptKey, arrEnts);

AcDbPoint* ptEnt = new AcDbPoint(ptKey);
AcDbObjectId idPointEnt;
pBTR->appendAcDbEntity(idPointEnt,ptEnt);
ptEnt->close();

CString sEnts;
for (int e=0; e<arrEnts.length(); e++)
{
ACHAR pBuff[255] = _T("");
arrEnts[e].handle().getIntoAsciiBuffer(pBuff);
CString sBuff;
sBuff.Format( (e==arrEnts.length()-1) ? _T("%s"): _T("%s,"), pBuff);
sEnts += sBuff;
}

CString sPromptReport;
sPromptReport.Format(_T("Point (%.4f, %.4f, %.4f) - Entities [%s]\n"),ptKey.x, ptKey.y, ptKey.z, sEnts);
acutPrintf(sPromptReport);
}

This is the sample DWG (remember to adjust the PTYPE):




And this is the prompt result:

Command: LINEINTS
We've found 8 lines in Model Space!
Checking intersection with tolerance 0.000100...
Point (49.4194, 7.7097, 0.0000) - Entities [1E0,1E1]
Point (43.8908, 18.4889, 0.0000) - Entities [1DF,1E0]
Point (37.2051, 11.5104, 0.0000) - Entities [1DF,1E1]
Point (32.4059, 13.0038, 0.0000) - Entities [1DE,1E1]
Point (33.7651, 7.9199, 0.0000) - Entities [1DE,1DF]
Point (30.4900, 20.1703, 0.0000) - Entities [1DD,1DE]
Point (20.6648, 16.6573, 0.0000) - Entities [1E1,1E2]
Point (22.1562, 13.7469, 0.0000) - Entities [1DD,1E2]
Point (24.4172, 15.4897, 0.0000) - Entities [1DD,1E1]
Point (17.0892, 9.8415, 0.0000) - Entities [1DC,1DD]
Point (16.3380, 17.5581, 0.0000) - Entities [1DB,1DC]

Full source code can be downloaded from here:

LineIntersections_VS2012_ARX2015.zip

Best regards!

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!

Thursday, December 25, 2014

Hello,

Here are my AU 2014 class material posted to Autodesk University website:

SD4865 : AutoCAD, JavaScript, and the Cloud
SD4861 : Creating AutoCAD Cross-Platform Plug-ins
SD4871 : Creating Professional Plug-ins for Autodesk Exchange Store

If you prefer to download the files directly, here is the Google Drive folder URL:

https://drive.google.com/folderview?id=0By7BVn8vCBxnZDhXRUJObGRxTUk&usp=sharing

Hope you enjoy!
Best regards.

Friday, June 27, 2014

Hello!

My 3 AU2014 classes were accepted:

Class ID: SD4861 
Class Title: Creating AutoCAD cross platform Plugins 
Class Type: Lecture 
 
Class ID: SD4865 
Class Title: AutoCAD, Javascript and the Cloud 
Class Type: Lecture 
 
Class ID: SD4871 
Class Title: Creating Professional Plugins for Autodesk Exchange Store 
Class Type: Lecture 

Meet you in Las Vegas!

Monday, May 16, 2011

Files moved to Google Docs

Hello,

I have moved all samples files to a Google Docs folder which can be accessed through the following link:

ObjectARX & Dummies Docs

It the above link does not work, copy and paste the following URL at your Browser:

https://docs.google.com/leaf?id=0By7BVn8vCBxnYjZjNWJhZjYtZjE3MC00ZjdiLTlmMjMtNTVhNTNjNjE0YjUy&hl=en

Cheers!

Wednesday, September 15, 2010

AutoCAD Mac announced and new Blog about ObjectARX

Hello,

I was really busy lately working behind the scenes with AutoCAD for Mac which was announced last August 31st by Autodesk.

I have attended this event and I'm totally excited about this new platform and all technology that it brings into the spot of AutoCAD community.

I have just created a new Blog entirely dedicated to this subject and I'm preparing some great material to share with you as soon as the product starts to ship.

More information here:

http://arxformac.blogspot.com/

Cheers!

Thursday, April 29, 2010

Visual Studio 2010

Hello,

I was playing around with the brand new Visual Studio 2010 and have found a really cool new feature. Actually this is something I'm waiting for years.

The problem:

Every new Visual Studio version requires you to create a new project and maintain it along the other versions. I had a situation once that I need to keep VS2005, VS2005 and VS2008 projects. What a pain! As soon as you add a new class to your project you need to replicate that to the other versions. It was chaotic!

The new feature:

VS2010 have introduced a new cool feature called "Platform Toolset". It allows you to target your build using specific VS libraries which allow you to build binaries as if you are using previous VS versions. Natively it comes with v100 and v90 platforms (v100 is the default). I did some testing targeting v90 and it really works. The generated DLL (in my case an ARX module) was totally compatible with the Host application (in this case AutoCAD).

More than that, with the ability to create your custom targets open a totally new world of VS projects management which will save you hours copying thing to keep your source code updated.

Further reading:

VS 2010 Enhancements

VS 2010 native Multi-targeting

I have used Visual Studio 2010 Professional Trial version to test this and you can download it from here:

Visual Studio 2010 Trial Download

Cheers!

Saturday, May 16, 2009

AU2008 Class

Hello,

Several people have asked me about some advice on creating custom classes inside ObjectARX.
I have made a detailed tutorial and presented it as a Class last year at Autodesk University.

There is an online video recording, PPT and PDF of this class at AU2008 website:
AU2008

For your convinience, I have also posted a direct link to the PDF:
Download

This is the link for related source files:
Projects_Exercise2.zip

This is the link for the Step6 converted to VS2010 SP1, using Toolset V90 and ObjectARX 2012. You will also need VS2008 SP1 installed to be able to compile it.
Exercise2_VS2010_ARX2012.zip

Best regards,
Fernando Malard.

Wednesday, February 11, 2009

AutoCAD 2010 announced!

Hello,

AutoCAD 2010 was announced:
http://finance.yahoo.com/news/Autodesk-Takes-3D-Design-and-prnews-14269988.html

Very exciting new features and better support for .NET programming for customizing entities (I plan to discuss this further soon).

Meanwhile, you may check these new features through a great collection of videos on the following page:

http://heidihewett.blogs.com/files/autocad2010videos.htm

Regards,
Fernando.

Tuesday, April 29, 2008

AU2008 Voting

Hello,

This year, AU (Autodesk University) classes will be rated by vote.
I have sent 3 classes under the Customization & Programming Power Track.
If you plan to attend AU2008 and would like to see one of my classes please take some time to vote through the following link:

AU2008 Voting

My classes are:

1) The Power of ObjectARX® - The Lab – AutoCAD – Level: Advanced

2) The Power of ObjectARX® - The Class – AutoCAD – Level: Intermediate

3) Creating Your Own Vertical Application Through AutoCAD® OEM – AutoCAD – Level: Intermediate


Hope these classes are approved and I hope you are able to attend this year!
Regards,

Thursday, March 27, 2008

Version Control

Hello,

Probably you will need or already need some version controlling on your software or on its modules.
This is made through the VS_VERSION_INFO resource inside C++ projects and through AssemblyInfo.cs file inside C# projects.

I have found an old but up to date tool (runs from VS2002 to VS2008) which allows you to easily manage these version informations. This tool, from Julijan Sribar, is an AddIn which tracks all opened projects and allow you to manage each version information. This tool is provided for free and its source code is also available for download: Versioning Controlled Build

Another issue is how to get this information at runtime to display, for instance, this version at an "About" like dialog inside your product. To do that in VC++ we need to read the VS_VERSION_INFO resource and get what we want. There is also another great article Retrieving version information from your local application's resource, from luetz,explaining how to do that.

Through C# there is no big deal, you can read the version information from AssemblyInfo as follows:

System.Reflection.Assembly oAssembly = System.Reflection.Assembly.GetExecutingAssembly();
System.Diagnostics.FileVersionInfo oFileVersionInfo = FileVersionInfo.GetVersionInfo(oAssembly.Location) ;
MessageBox.Show("Version Info", oFileVersionInfo.ProductVersion);

Hope this help you to keep your file versions organized and updated!
Cheers!

Tuesday, March 25, 2008

Blog Classes content update

Hello,

I have updated and fixed some classes sample code that are not UNICODE aware that will not compile inside VS2005 (ObjectARX 2007, 2008 and 2009).

Basically, I have changed:

- Add _T() macro to all strings;
- Changed strcpy() to _tcscpy() which is UNICODE aware;
- Changed char* to TCHAR* or to ACHAR* pointers;

Important: ACHAR is a typedef present inside "AdAChar.h" ObjectARX header. If you are trying to compile for non-UNICODE ObjectARX versions replace ACHAR* by TCHAR* (or char*) and you should get out of compilation errors.

Cheers!

Wednesday, March 19, 2008

VS2005 Samples

Hello,

I have updated some VS2002 samples to VS2005.
There are two new files, ending with "VC8" which are the VS2005 converted solution/projects.

You can download these projects from here:

VS2005 Samples

These should compile fine with ObjectARX 2007, 2008 and 2009.
Note that if you plan to be 100% compatible with these 3 releases you will need to use the 2007 version of ObjectARX SDK.

Cheers!

Wednesday, February 13, 2008

AutoCAD 2009

Hello,

Yesterday, February 12th, Autodesk has officially announced its 2009 product line.
Read more about here:

http://www.worldpressdays08.com/pages/page.cfm?action=products&sub1=1

AutoCAD 2009 (codename Raptor) will implement several new features like these major ones:

- View Cube (easy 3D view);
- Steering Wheel (easy 3D navigation);
- Office like Ribbon interface;
- Menu Browser;
- Action recorder;
- Geographic location;
- Modeless Layer manager (works now like a toolpallete);

There are much more and you may find these detailed features soon at Autodesk website.

My friend, Shaan Hurley, have a more detailed list at his Blog:
http://autodesk.blogs.com/between_the_lines/2008/02/the-2009-produc.html

Regarding to programming aspects, AutoCAD 2009 is backward compatible with 2007 and 2008. This way an application compiled with ObjectARX 2007 will be able to run inside all these 3 versions.

Actually, AutoCAD 2009 was built using VS2005 Service Pack 1 but if you plan to keep your project backward compatible it is recommended to use VS2005 without Service Pack.

Probably the next version of AutoCAD will break the binary compatibility with 2007,2008 and 2009 and will use VS2008. Autodesk seems to be aligned with Microsoft Visual Studio evolution and will try to make only binary compatibility break on every 3 releases.

Cheers!

Monday, January 14, 2008

AutoCAD GUI tests

Hello,

I would like to introduce a new Blog this year. It will be about AutoCAD Applications GUI tests. The idea behind this Blog is to discuss methods and tools that could be used to test all types of AutoCAD applications against AutoCAD interface to reach a better test experience approaching the real user environment.

If you are interested on discuss this I would like to invite you to visit my new Blog at:

http://acadguitest.blogspot.com/

Best regards,

Tuesday, December 04, 2007

AU2007 was huge!

Hello,

AU2007 was really huge. The initial estimations are around 10.000 attendees.
What can we expect for AU2008 ? 15.000 ???

I will post on the next days my two courses materials but as one of my classes was recorded here is the link for the presentation (you will need to register to AU Online to be able to see the video):

http://autodesk.mediasite.com/autodesk/autologinform/?peid=7a7838a8-1bc6-4d68-8b03-3158b14c023f

Best Regards.

Monday, October 22, 2007

AutoCAD next version ?

Hello,

We are approaching the end of 2007 and if Autodesk keep its policy with annual releases of AutoCAD we will probably have soon the next release which would be 2009.

I would like to ask you what do you expect as new features of this upcoming release. Please add your comments to this post and soon we will see what's new from the next AutoCAD.

Meanwhile, cross your fingers and wait for the official announcement.

Best regards,

Tuesday, August 28, 2007

AU2007

Hello,

For those who will have the opportunity to participate on this year's Autodesk University at Las Vegas I would like to suggest my two classes:

CP401-2
The Power of ObjectARX®

CP405-1
Creating Your Own Vertical Application Through AutoCAD® OEM

Registration:
http://au.autodesk.com/2007/register/

Hope to meet you in Vegas this year!
Regards,
Fernando.

Wednesday, May 30, 2007

AUGI Brazil

Hello,

I would like to invite all Portuguese speaking world to visit the brand new AUGI Brasil website.

AUGI Br was officially launched today (30/05/2007) which is the same day AutoCAD 2008 is being officially announced here in Brazil.

http://www.augibr.com

Congratulations!

Fernando.