0% found this document useful (0 votes)
160 views33 pages

Autocad Devblog /autocad/)

The document discusses an AutoCAD DevBlog post about detecting CenterLine and CenterMark entities in AutoCAD. It explains that CenterLine and CenterMark are new entity types introduced in AutoCAD 2017 that are unnamed block references used for different purposes. While there is no public API to identify the type of entity, the post demonstrates using the non-COM property system to determine if an entity is a CenterLine or CenterMark by getting its name and point properties. Sample C++ code is provided to perform this check.

Uploaded by

nirmal suthar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
160 views33 pages

Autocad Devblog /autocad/)

The document discusses an AutoCAD DevBlog post about detecting CenterLine and CenterMark entities in AutoCAD. It explains that CenterLine and CenterMark are new entity types introduced in AutoCAD 2017 that are unnamed block references used for different purposes. While there is no public API to identify the type of entity, the post demonstrates using the non-COM property system to determine if an entity is a CenterLine or CenterMark by getting its name and point properties. Sample C++ code is provided to perform this check.

Uploaded by

nirmal suthar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 33

AutoCAD DevBlog https://adndevblog.typepad.

com/autocad/page/3/

AutoCAD DevBlog
(https://adndevblog.typepad.com
/autocad/)

11/23/2018
AutoCAD 2019 Migration Steps : NET &
ObjectARX
(https://adndevblog.typepad.com
/autocad/2018/11/autocad-2019-
migration-steps-net-objectarx.html)
By Madhukar Moogala (https://adndevblog.typepad.com/autocad
/Madhukar-Moogala.html)
By now most of the developers might have got chance to peek into
AutoCAD 2019.

Unfortunately some users experienced issues with License


Management and Downloading.

The problem is being pursued rigorously by our Installation and


Deployment teams.

Please find the video tutorial which demonstrates about VS 2017


toolset requirements and other basic migration issues.

1 of 33 5/24/2020, 9:13 PM
AutoCAD DevBlog https://adndevblog.typepad.com/autocad/page/3/

Posted at 04:33 AM in AutoCAD (https://adndevblog.typepad.com/autocad


/autocad/), Madhukar Moogala (https://adndevblog.typepad.com/autocad
/madhukar-moogala/), ObjectARX (https://adndevblog.typepad.com/autocad
/objectarx/) | Permalink (https://adndevblog.typepad.com/autocad/2018/11
/autocad-2019-migration-steps-net-objectarx.html) | Comments (3)
(https://adndevblog.typepad.com/autocad/2018/11/autocad-2019-migration-
steps-net-objectarx.html#comments)

10/11/2018
Pattern generation of linetype with text
on polyline entity
(https://adndevblog.typepad.com
/autocad/2018/10/pattern-generation-
of-linetype-with-text-on-polyline-
entity.html)
By Deepak Nadig (https://adndevblog.typepad.com/autocad
/deepak-nadig.html)

Generating linetype with text on a Polyline entity could result


in linetype pattern generated continuously across all vertices as
below image. This is because the linetype generation property of
Polyline is ON

2 of 33 5/24/2020, 9:13 PM
AutoCAD DevBlog https://adndevblog.typepad.com/autocad/page/3/

(https://adndevblog.typepad.com
/.a/6a0167607c2431970b022ad3b7c358200b-pi)
Interactively this can be changed by issuing PEDIT command,
setting Ltype gen as Off.

Command: PEDIT
Enter an option [Open/Join/Width/Edit vertex/Fit/Spline
/Decurve/Ltype gen/Reverse/Undo]: L
Enter polyline linetype generation option [ON/OFF]
<On>: OFF

Via .NET API, Polyline entity has no property to change this. Thanks
to Polyline2d.LinetypeGenerationOn property, we can convert the
Polyline entity to Polyline2d and set this property false. Code sample
shown below with the output image.

3 of 33 5/24/2020, 9:13 PM
AutoCAD DevBlog https://adndevblog.typepad.com/autocad/page/3/

// code modified from the link


//http://through-the-interface.typepad.com/thro
ugh_the_interface/2008/01/creating-a-comp.html
[CommandMethod("CCL")]
public void CreateComplexLinetype()
{
Document doc =
Application.DocumentManager.MdiActiveDo
cument;
Database db = doc.Database;
Editor ed = doc.Editor;
Transaction tr =
db.TransactionManager.StartTransaction
();
using (tr)
{
TextStyleTable tt =
(TextStyleTable)tr.GetObject(
db.TextStyleTableId,
OpenMode.ForRead
);
LinetypeTable lt =
(LinetypeTable)tr.GetObject(
db.LinetypeTableId,
OpenMode.ForWrite
);
LinetypeTableRecord ltr =
new LinetypeTableRecord();

ltr.Name = "COLD_WATER_SUPPLY";
ltr.AsciiDescription =
"Cold water supply ---- CW ---- CW
---- CW ----";
ltr.PatternLength = 0.9;
ltr.NumDashes = 3;
// Dash #1
ltr.SetDashLengthAt(0, 0.5);
// Dash #2
ltr.SetDashLengthAt(1,-0.2);

4 of 33 5/24/2020, 9:13 PM
AutoCAD DevBlog https://adndevblog.typepad.com/autocad/page/3/

ltr.SetShapeStyleAt(1, tt["Standard"]);
ltr.SetShapeNumberAt(1, 0);
ltr.SetShapeScaleAt(1, 0.1);
ltr.SetTextAt(1, "CW");
ltr.SetShapeRotationAt(1, 0);
ltr.SetShapeOffsetAt(1, new Vector2d(0,
-0.05));
// Dash #3
ltr.SetDashLengthAt(2, -0.2);

// Add the new linetype to the linetype


table
ObjectId ltId = lt.Add(ltr);
tr.AddNewlyCreatedDBObject(ltr, true);
// Create a test line with this linetyp
e
BlockTable bt =
(BlockTable)tr.GetObject(
db.BlockTableId,
OpenMode.ForRead
);
BlockTableRecord btr =
(BlockTableRecord)tr.GetObject(
bt[BlockTableRecord.ModelSpace],
OpenMode.ForWrite
);

using (Polyline acPoly = new Polyline


())
{
acPoly.SetDatabaseDefaults(db);
acPoly.AddVertexAt(0, new Point2d
(0, 0), 0, 0, 0);
acPoly.AddVertexAt(1, new Point2d
(0, 2), 0, 0, 0);
acPoly.AddVertexAt(2, new Point2d
(2, 2), 0, 0, 0);
acPoly.AddVertexAt(3, new Point2d
(2, 0), 0, 0, 0);

5 of 33 5/24/2020, 9:13 PM
AutoCAD DevBlog https://adndevblog.typepad.com/autocad/page/3/

acPoly.Closed = true;
btr.AppendEntity(acPoly);
tr.AddNewlyCreatedDBObject(acPoly,
false);
Polyline2d poly2 = acPoly.ConvertTo
(true);
poly2.LinetypeGenerationOn = false;
poly2.LinetypeId = ltId;
tr.AddNewlyCreatedDBObject(poly2, t
rue);
}
tr.Commit();
}
}

Result :

(https://adndevblog.typepad.com
/.a/6a0167607c2431970b022ad37201be200c-pi)
Posted at 04:48 AM in .NET (https://adndevblog.typepad.com/autocad/net/),
AutoCAD (https://adndevblog.typepad.com/autocad/autocad/), Deepak A S Nadig
(https://adndevblog.typepad.com/autocad/deepak-a-s-nadig/) | Permalink
(https://adndevblog.typepad.com/autocad/2018/10/pattern-generation-of-
linetype-with-text-on-polyline-entity.html) | Comments (2)
(https://adndevblog.typepad.com/autocad/2018/10/pattern-generation-of-
linetype-with-text-on-polyline-entity.html#comments)

09/10/2018

6 of 33 5/24/2020, 9:13 PM
AutoCAD DevBlog https://adndevblog.typepad.com/autocad/page/3/

How to Detect CenterLine and


CenterMark Entities
(https://adndevblog.typepad.com
/autocad/2018/09/how-to-detect-
centerline-and-centermark-
entities.html)
By Madhukar Moogala (https://adndevblog.typepad.com/autocad
/Madhukar-Moogala.html)

CenterLine and CenterMark are two new entities based on


AcDbBlockReferenes introduced in AutoCAD 2017, they are basically
unnamed blockreference catering different purpose.

For more information on these two entities – CenterLine &


CenterMark (https://knowledge.autodesk.com/support/autocad
/learn-explore/caas/CloudHelp/cloudhelp/2017/ENU/AutoCAD-
Core/files/GUID-C078E9E4-FF38-4BA7-B72B-F2DAB92AFC99-
htm.html)

In this post we will look at how to identifying if the underlying


entities is a CenterLine or CenterMark objects, unfortunately there
isn’t a public API to get to know what is the type of the Entity.

However through using Non-Com property system we can figure out


if the entity is whether a CenterLine or CenterMark.

7 of 33 5/24/2020, 9:13 PM
AutoCAD DevBlog https://adndevblog.typepad.com/autocad/page/3/

void testIt() {

ads_name ename;
ads_point pt;
AcDbObjectId objId = AcDbObjectId::kN
ull;
AcDbEntity* pEnt = nullptr;
if (RTNORM != acedEntSel(_T(""), enam
e, pt)) return;
if (!eOkVerify(acdbGetObjectId(objId,
ename))) return;
if (!eOkVerify(acdbOpenAcDbEntity(pEn
t, objId, AcDb::kForRead))) return;
isCenterLineOrNot(pEnt);

Utils

8 of 33 5/24/2020, 9:13 PM
AutoCAD DevBlog https://adndevblog.typepad.com/autocad/page/3/

void getAttInfo(const AcRxAttribute * att,


const AcRxObject * member,
AcString & attInfo)
{
if (att->isA() == AcRxCOMAttribute::d
esc())
{
AcRxCOMAttribute * a = AcRxCOMA
ttribute::cast(att);
attInfo.format(_T("\n%s - %s"),
att->isA()->name(), a->name());
}
else if (att->isA() == AcRxUiPlacemen
tAttribute::desc())
{
AcRxUiPlacementAttribute* a = A
cRxUiPlacementAttribute::cast(att);
attInfo.format(
_T("\n%s - %s - %f"),
att->isA()->name(),
a->getCategory(member),
a->getWeight(member));
}
else
{
if (att->isA() != nullptr)
{
attInfo.format(_T("\n%
s"),
att->isA()->name());
}
}
}

void printValues(AcRxObject * entity,


const AcRxMember * member,
Adesk::Boolean& isCenterLine)
{

9 of 33 5/24/2020, 9:13 PM
AutoCAD DevBlog https://adndevblog.typepad.com/autocad/page/3/

Acad::ErrorStatus err = Acad::eOk;

AcString strValue;
AcRxProperty * prop = AcRxProperty::c
ast(member);
if (prop != NULL)
{
AcRxValue value;

if ((err = prop->getValue(entit
y, value)) == Acad::eOk)
{
ACHAR * szValue = NULL;

int buffSize = value.toS


tring(NULL, 0);
if (buffSize > 0)
{
buffSize++;
szValue = new ACH
AR[buffSize];
value.toString(sz
Value, buffSize);
}

strValue.format(_T("%s =
%s"),
value.type().name(),
(szValue == NULL) ? _T("
none") : szValue);

if (szValue)
delete szValue;
}
else
{
strValue.format(_T("Erro

10 of 33 5/24/2020, 9:13 PM
AutoCAD DevBlog https://adndevblog.typepad.com/autocad/page/3/

r Code = %d"), err);


}
}

AcString str;
str.format(_T("\n%s - %s [%s]"), memb
er->isA()->name(),
member->name(), strValue.k
ACharPtr());
AcString memberName;
memberName.format(_T("%s"), member->n
ame());
if (0 == memberName.collateNoCase(_T
("IsCenterLine")))
{
AcString isTrue(strValue.kAChar
Ptr());
if (isTrue.find(_T("1")) > 0) {
isCenterLine = Adesk::kT
rue;
}

}
acutPrintf(str);

const AcRxAttributeCollection & atts


= member->attributes();

for (int i = 0; i < atts.count();


i++)
{
const AcRxAttribute * att = att
s.getAt(i);
AcString attInfo;
getAttInfo(att, member, attInf
o);
acutPrintf(attInfo);
}

11 of 33 5/24/2020, 9:13 PM
AutoCAD DevBlog https://adndevblog.typepad.com/autocad/page/3/

if (member->children() != NULL)
{
for (int i = 0; i < member->chi
ldren()->length(); i++)
{
const AcRxMember * subMe
mber =
member->children()->at
(i);
printValues(entity, subM
ember, isCenterLine);
}
}
}
Adesk::Boolean isCenterLineOrNot(AcDbEntity*
pEnt)
{
AcRxMemberIterator * iter =
AcRxMemberQueryEngine::theEngine()->n
ewMemberIterator(pEnt);
Adesk::Boolean isCenterLine = Adesk::
kFalse;
for (; !iter->done(); iter->next())
{
printValues(pEnt, iter->current
(), isCenterLine);
}
return isCenterLine;
}

Update:

Thanks to Engineering Colleague Huyau Liu for this tip

12 of 33 5/24/2020, 9:13 PM
AutoCAD DevBlog https://adndevblog.typepad.com/autocad/page/3/

enum CenterType
{
CenterMark = 0,
CenterLine
};
AcString SmartCenters[] = { L"CenterMark",
L"CenterLine" };

Acad::ErrorStatus getTypeOfSmartCenterObject
(const AcDbObjectId& blockRefObjId , CenterT
ype& type)
{
AcDbSmartObjectPointer pCenter(block
RefObjId, AcDb::kForRead, true);
if (pCenter.openStatus() != Acad::eO
k)
return Acad::eNullEntityPoin
ter;

AcDbObjectIdArray actionIds;
Acad::ErrorStatus err = AcDbAssocAct
ion::getActionsDependentOnObject(pCenter, fa
lse, true, actionIds);
if (!eOkVerify(err))
return err;

for (int i = 0; i < actionIds.length


(); i++)
{
AcDbObjectId actionBody = Ac
DbAssocAction::actionBody(actionIds[i]);
auto objClass = actionBody.o
bjectClass();
AcString objClassName = objC
lass->name();

if (objClassName == L"AcDbCe
nterMarkActionBody") {

13 of 33 5/24/2020, 9:13 PM
AutoCAD DevBlog https://adndevblog.typepad.com/autocad/page/3/

type = CenterType::C
enterMark;
return Acad::eOk;
}
else if (objClassName == L"A
cDbCenterLineActionBody") {
type = CenterType::C
enterLine;
return Acad::eOk;
}
else;
}

return Acad::eNotApplicable;

CenterType type;
if (eOkVerify(getTypeOfSmartCenterObject(o
bjId, type)))
{
acutPrintf(_T("CenterType : %s"), SmartCe
nters[type].kACharPtr());
}

.NET Port courtesy Alexander Rivilis, Thank you :)

14 of 33 5/24/2020, 9:13 PM
AutoCAD DevBlog https://adndevblog.typepad.com/autocad/page/3/

public void TestCenter()


{
Document doc = Application.DocumentManager.M
diActiveDocument;
if (doc == null) return;
Editor ed = doc.Editor;
Database db = doc.Database;
PromptEntityOptions prOpt = new PromptEntity
Options("Select block: ");
prOpt.SetRejectMessage("Not a block!");
prOpt.AddAllowedClass(typeof(BlockReferenc
e), true);
PromptEntityResult prRes = ed.GetEntity(prOp
t);
if (prRes.Status != PromptStatus.OK) return;
using (Transaction tr = doc.TransactionManag
er.StartTransaction())
{
var br =
tr.GetObject(prRes.ObjectId, OpenMode.Fo
rRead) as BlockReference;
try
{
var idCols = AssocAction.GetActionsD
ependentOnObject(br, false, true);
if (idCols.Count > 0)
{
foreach (ObjectId id in idCols)
{
ObjectId idAct = AssocActio
n.GetActionBody(id);
if (idAct.ObjectClass.Name =
= "AcDbCenterMarkActionBody")
{
ed.WriteMessage("\nIt is
CenterMark");
break;
}

15 of 33 5/24/2020, 9:13 PM
AutoCAD DevBlog https://adndevblog.typepad.com/autocad/page/3/

if (idAct.ObjectClass.Name =
= "AcDbCenterLineActionBody")
{
ed.WriteMessage("\nIt is
CenterLine");
break;
}
}
}
}
catch { };
tr.Commit();
}

Posted at 05:02 PM in AutoCAD (https://adndevblog.typepad.com/autocad


/autocad/), Madhukar Moogala (https://adndevblog.typepad.com/autocad
/madhukar-moogala/), ObjectARX (https://adndevblog.typepad.com/autocad
/objectarx/) | Permalink (https://adndevblog.typepad.com/autocad/2018/09
/how-to-detect-centerline-and-centermark-entities.html) | Comments (1)
(https://adndevblog.typepad.com/autocad/2018/09/how-to-detect-centerline-
and-centermark-entities.html#comments)

08/03/2018
Creating a RealDWG Installer with Wix
Toolset
(https://adndevblog.typepad.com
/autocad/2018/08/creating-a-realdwg-
installer-with-wix-toolset.html)
By Madhukar Moogala (https://adndevblog.typepad.com/autocad
/Madhukar-Moogala.html)
This post contains a video demonstration using Wix toolset to create
RealDWG installer.

Though video targets to RealDWG 2019 using Visual Studio 2017 and
Wix Toolset 3.11, the presentation is suitable for all previous versions

16 of 33 5/24/2020, 9:13 PM
AutoCAD DevBlog https://adndevblog.typepad.com/autocad/page/3/

with minor tweaks about release version numbers.


Source of project is hosted in Github (https://github.com
/MadhukarMoogala/RealDWGInstallerWithWix)

Posted at 03:22 AM in Madhukar Moogala (https://adndevblog.typepad.com


/autocad/madhukar-moogala/) | Permalink (https://adndevblog.typepad.com
/autocad/2018/08/creating-a-realdwg-installer-with-wix-toolset.html) |
Comments (0) (https://adndevblog.typepad.com/autocad/2018/08/creating-
a-realdwg-installer-with-wix-toolset.html#comments)

07/30/2018
Identify Mechanical Desktop file(MDT)
using .NET
(https://adndevblog.typepad.com
/autocad/2018/07/identify-
mechanical-desktop-filemdt-using-
net.html)
By Deepak Nadig (https://adndevblog.typepad.com/autocad
/deepak-nadig.html)
Recently, we had a customer query regarding distinguishing an

17 of 33 5/24/2020, 9:13 PM
AutoCAD DevBlog https://adndevblog.typepad.com/autocad/page/3/

AutoCAD Mechanical desktop file among a set of drawing files.


Answer:
Mechanical desktop should have entry named AmdtFileType with a
value of 84 in the Custom tab of DWGPROPS(image)

(https://adndevblog.typepad.com
/.a/6a0167607c2431970b022ad3852eb8200d-pi)

One of the ways to distinguish a Autodesk Mechanical desktop


file could be to retrieve and check for the custom property as below.
Note : File to be checked is read as a side database in the code
below.

18 of 33 5/24/2020, 9:13 PM
AutoCAD DevBlog https://adndevblog.typepad.com/autocad/page/3/

[CommandMethod("testMdtFile")]
public static void testMdtFile()
{
Editor ed = Application.DocumentManager.Mdi
ActiveDocument.Editor;
try
{
using (Database db = new Database(fals
e, true))
{
db.ReadDwgFile(@"c:\temp\testMDT.dw
g", FileOpenMode.OpenForReadAndAllShare, false,
null);
db.CloseInput(true);
string val = GetCustomProperty(db,
"AmdtFileType");
System.Windows.Forms.MessageBox.Sho
w("Value of AmdtFileType is " + val);
}
}
catch (System.Exception ex)
{
ed.WriteMessage(ex.ToString());
}
}
public static string GetCustomProperty(Database
db, string key)
{
DatabaseSummaryInfoBuilder sumInfo = new Da
tabaseSummaryInfoBuilder(db.SummaryInfo);
IDictionary custProps = sumInfo.CustomPrope
rtyTable;
return (string)custProps[key];
}

Posted at 09:52 PM in .NET (https://adndevblog.typepad.com/autocad/net/),


2017 (https://adndevblog.typepad.com/autocad/2017/), AutoCAD
(https://adndevblog.typepad.com/autocad/autocad/), Deepak A S Nadig
(https://adndevblog.typepad.com/autocad/deepak-a-s-nadig/) | Permalink
(https://adndevblog.typepad.com/autocad/2018/07/identify-mechanical-

19 of 33 5/24/2020, 9:13 PM
AutoCAD DevBlog https://adndevblog.typepad.com/autocad/page/3/

desktop-filemdt-using-net.html) | Comments (0)


(https://adndevblog.typepad.com/autocad/2018/07/identify-mechanical-
desktop-filemdt-using-net.html#comments)

05/04/2018
Set origin while creating a hatch using
.NET (https://adndevblog.typepad.com
/autocad/2018/05/set-origin-while-
creating-a-hatch-using-net.html)
By Deepak Nadig (https://adndevblog.typepad.com/autocad
/deepak-nadig.html)
We had an issue raised by a customer regarding setting
origin(image) during hatch creation.

(https://adndevblog.typepad.com
/.a/6a0167607c2431970b0224e03718bd200d-pi)
It was found that origin of hatch has to be set in a transaction other
than the one in which it is created for it to work correctly.
Below code can be used for testing :

20 of 33 5/24/2020, 9:13 PM
AutoCAD DevBlog https://adndevblog.typepad.com/autocad/page/3/

[CommandMethod("setOrginHatch")]
public void setOriginHatch()
{
Document doc = Application.DocumentManager.
MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;

ObjectId mHatchId;
Hatch mHatch = new Hatch();
using (Transaction tr1 = db.TransactionMana
ger.StartTransaction())
{
BlockTable bt = (BlockTable)tr1.GetObje
ct(doc.Database.BlockTableId, OpenMode.ForRea
d);
BlockTableRecord btr = (BlockTableRecor
d)tr1.GetObject(db.CurrentSpaceId, OpenMode.For
Write);

Point2d pt = new Point2d(0, 0);


Polyline mPolyline = new Polyline(4);
mPolyline.AddVertexAt(0, pt, 0.0, -1.0,
-1.0);
mPolyline.Normal = Vector3d.ZAxis;
mPolyline.AddVertexAt(1, new Point2d(p
t.X + 10, pt.Y), 0.0, -1.0, -1.0);
mPolyline.AddVertexAt(2, new Point2d(p
t.X + 10, pt.Y + 5), 0.0, -1.0, -1.0);
mPolyline.AddVertexAt(3, new Point2d(p
t.X, pt.Y + 5), 0.0, -1.0, -1.0);
mPolyline.Closed = true;

ObjectId mPlineId;
mPlineId = btr.AppendEntity(mPolyline);
tr1.AddNewlyCreatedDBObject(mPolyline,
true);

ObjectIdCollection ObjIds = new ObjectI

21 of 33 5/24/2020, 9:13 PM
AutoCAD DevBlog https://adndevblog.typepad.com/autocad/page/3/

dCollection();
ObjIds.Add(mPlineId);

Vector3d normal = new Vector3d(0.0, 0.


0, 1.0);
mHatch.Normal = normal;
mHatch.Elevation = 0.0;
mHatch.PatternScale = 2.0;
mHatch.SetHatchPattern(HatchPatternTyp
e.PreDefined, "NET");
mHatch.ColorIndex = 1;
mHatch.PatternAngle = 2;

//trying to set origin here does not wo


rk
//Point2d setOrigin = new Point2d(6.69
8, 2.78);
//mHatch.Origin = setOrigin;

btr.AppendEntity(mHatch);
tr1.AddNewlyCreatedDBObject(mHatch, tru
e);

mHatch.Associative = true;
mHatch.AppendLoop(HatchLoopTypes.Outerm
ost, ObjIds);
mHatch.EvaluateHatch(true);

//get the ObjectId of hatch


mHatchId = mHatch.ObjectId;

tr1.Commit();
}
//to set the origin use another transaction
using (Transaction tr2 = doc.TransactionMan
ager.StartTransaction())
{
Entity ent = (Entity)tr2.GetObject(mHat
chId, OpenMode.ForWrite);

22 of 33 5/24/2020, 9:13 PM
AutoCAD DevBlog https://adndevblog.typepad.com/autocad/page/3/

if (ent != null)
{
Hatch nHatch = ent as Hatch;
String hatchName = nHatch.PatternNa
me;
Point2d setOrigin = new Point2d(6.6
98, 2.78);
nHatch.Origin = setOrigin;
nHatch.SetHatchPattern(HatchPattern
Type.PreDefined, hatchName);
nHatch.EvaluateHatch(true);
nHatch.Draw();
}
tr2.Commit();
}
}

Posted at 04:00 AM in .NET (https://adndevblog.typepad.com/autocad/net/),


AutoCAD (https://adndevblog.typepad.com/autocad/autocad/) | Permalink
(https://adndevblog.typepad.com/autocad/2018/05/set-origin-while-creating-
a-hatch-using-net.html) | Comments (1) (https://adndevblog.typepad.com
/autocad/2018/05/set-origin-while-creating-a-hatch-using-net.html#comments)

05/01/2018
Running OEMMAKEWIZARD from
Command Line
(https://adndevblog.typepad.com
/autocad/2018/05/running-
oemmakewizard-from-command-
line.html)
By Madhukar Moogala (https://adndevblog.typepad.com/autocad
/Madhukar-Moogala.html)

This is small batch script may be useful for OEM Developers.


Once you have created your project, you can run the AutoCAD OEM
Make Wizard from the command line to automate building your
product. In this mode, you can use any of the build options available
on the Build Your Product page of the AutoCAD OEM Make Wizard.

23 of 33 5/24/2020, 9:13 PM
AutoCAD DevBlog https://adndevblog.typepad.com/autocad/page/3/

Enter the following command to display a Help screen describing the


command-line options for the AutoCAD OEM Make Wizard:
oemmakewizard /?

Build Options:

24 of 33 5/24/2020, 9:13 PM
AutoCAD DevBlog https://adndevblog.typepad.com/autocad/page/3/

Path Options
/PA: Specifies the path for AutoCAD OEM loc
ation
/PB: Specifies the path for bitmap location
Import Options
/IC: Specifies a file for enabling\disablin
g AutoCAD commands
/IAS: Specifies a file for adding your comm
ands
/IRS: Specifies a file that allows you to r
emove user specified commands or setvars
Build Options
/BALL Builds all (does not include the file
s executed by /BT command)
/BA Binds ObjectARX/Core ObjectARX applicat
ions
/BB Binds managed applications
/BBA Binds managed ObjectARX applications
/BL Binds AutoLISP applications
/BD Binds DLL modules
/BV Bind DVB macros
/BC Copies files
/BT Builds type libraries and registry file
s
/BT+ Registers associated registry files
/BI Change icons
/BR Rebuilds resources
/BR+ Rebuilds resources and uses settings w
ith AutoCAD OEM
/BR- Rebuilds resources, but does not bind
the DLLs
/STOP Interrupts batch mode when errors are
encountered
/? Displays the Help screen for all command
options
1 @echo off
2 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
3 :::
4 ::: Created by Madhukar Moogala

25 of 33 5/24/2020, 9:13 PM
AutoCAD DevBlog https://adndevblog.typepad.com/autocad/page/3/

5 ::: Autodesk Devtech


6 :::
7 :::
8 ::: This batch program builds an AutoCAD OEM Product, TestCAD. This product is used
9 ::: as the host application for the OEM Build and Diagnositics.
10 :::
11 :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
12 ::
13 ::"=================================================================================
14 :: @see MIT License
15 :: =================================================================================
16 ::
17 set ProjectName=TestCAD
18 set BuildDir=C:\users\default\Documents\AutoCAD OEM 2019\build
19 set ProjectDir=C:\users\default\Documents\AUTOCAD OEM 2019\projects\
20 set EXEDIR=c:\program files\autodesk\autocad oem 2019 - english
21 set ACSUP=c:\program files\autodesk\autocad oem 2019 - english\Support
22 set ACTOOLKIT=C:\Users\Default\Documents\AutoCAD OEM 2019\Projects\TestCAD\Toolkit
23 set PRODUCTNAME=TestWorks
24 set PRODNAME=TestCAD
25 set ACBMP=c:\program files\autodesk\autocad oem 2019 - english\Toolkit\Bitmaps;c:\prog
26 set LOCALROOT=C:\Users\moogalm\AppData\Local\Autodesk\AutoCAD OEM 2019\R23\enu\
27 set ROAMINGROOT=C:\Users\moogalm\AppData\Roaming\Autodesk\AutoCAD OEM 2019\R23\enu\
28 ::Setting directories sto PATH will Oemwizard to find and execute properly
29 set PATH=%PATH%;C:\Users\Default\Documents\AutoCAD OEM 2019\Projects\TestCAD\Toolkit;c
30 :: Please enter your keycode, DDFiveDigitsofSerialNumberMM
31 set KeyCode=DDxxxxxMM
32 set LogProfile="%ACTOOLKIT%\OemStampxml.log"
33 set ErrProfile="%ACTOOLKIT%\OemStampxml.err"
34
35 cd "%ProjectDir%"
36 if exist %LogProfile% (
37 del %LogProfile%
38 echo %LogProfile% deleted)
39 if exist %ErrProfile% (
40 del %LogProfile%
41 echo %ErrProfile% deleted
42 )
43 "%EXEDIR%\Toolkit\oemmakewizard.exe" %ProjectName% %KeyCode% /BALL /BT /BR /PA:
44

26 of 33 5/24/2020, 9:13 PM
AutoCAD DevBlog https://adndevblog.typepad.com/autocad/page/3/

view raw (https://gist.github.com/MadhukarMoogala


/610c8fd96d622c2c935f9ee5bcf958ba
/raw/c368e64859366eae30ab19909c9c10c7316ec72f/Build-AutoCADOem.bat)
Build-AutoCADOem.bat (https://gist.github.com/MadhukarMoogala
/610c8fd96d622c2c935f9ee5bcf958ba#file-build-autocadoem-bat) hosted with by
GitHub (https://github.com)

Posted at 09:25 PM in AutoCAD (https://adndevblog.typepad.com/autocad


/autocad/), AutoCAD OEM (https://adndevblog.typepad.com/autocad/autocad-
oem/), Madhukar Moogala (https://adndevblog.typepad.com/autocad/madhukar-
moogala/) | Permalink (https://adndevblog.typepad.com/autocad/2018/05
/running-oemmakewizard-from-command-line.html) | Comments (3)
(https://adndevblog.typepad.com/autocad/2018/05/running-oemmakewizard-
from-command-line.html#comments)

04/26/2018
Viewing LineType Appearance
(https://adndevblog.typepad.com
/autocad/2018/04/viewing-linetype-
appearance.html)
By Madhukar Moogala (https://adndevblog.typepad.com/autocad
/Madhukar-Moogala.html)
I have recieved this query, user would like to get appearance of
LineTypeRecord or LineTypes through API.

We can use Comments API to gets the Linetype appearance in the


form of ascii string.

Code:

27 of 33 5/24/2020, 9:13 PM
AutoCAD DevBlog https://adndevblog.typepad.com/autocad/page/3/

public static void LineTypeAppearance()


{
Database database = HostApplicat
ionServices.WorkingDatabase;
var ed = AcCore.Application.Docu
mentManager.MdiActiveDocument.Editor;
using (Transaction t = database.
TransactionManager.StartTransaction())
{
var symTable = (SymbolTable)
t.GetObject(database.LinetypeTableId,

OpenMode.ForRead);
foreach (ObjectId id in symT
able)
{
var symbol = (LinetypeTa
bleRecord)t.GetObject(id, OpenMode.ForRead);
ed.WriteMessage(string.F
ormat("\nName: {0}\t Appearance: {1}",

symbol.Name, symbol.Comments));
}

t.Commit();
}
}

Output
Name: BYBLOCK Desc:
Name: BYLAYER Desc:
Name: CONTINUOUS Desc: Solid line
Name: Wall Base|CENTER Desc: Center ____ _
____ _ ____ _ ____ _ ____ _ ____
Name: Wall Base|DASHED Desc: Dashed __ __ _
_ __ __ __ __ __ __ __ __ __ __ _

Posted at 10:01 PM in .NET (https://adndevblog.typepad.com/autocad/net/),

28 of 33 5/24/2020, 9:13 PM
AutoCAD DevBlog https://adndevblog.typepad.com/autocad/page/3/

AutoCAD (https://adndevblog.typepad.com/autocad/autocad/), Madhukar


Moogala (https://adndevblog.typepad.com/autocad/madhukar-moogala/) |
Permalink (https://adndevblog.typepad.com/autocad/2018/04/viewing-linetype-
appearance.html) | Comments (1) (https://adndevblog.typepad.com/autocad
/2018/04/viewing-linetype-appearance.html#comments)

04/22/2018
Determine the radius and center of
circular cone base using .NET
(https://adndevblog.typepad.com
/autocad/2018/04/determine-the-
radius-and-center-of-circular-cone-
base-using-net-.html)
By Deepak Nadig (https://adndevblog.typepad.com/autocad
/deepak-nadig.html)

(https://adndevblog.typepad.com
/.a/6a0167607c2431970b0224e033ebde200d-pi)

We can make use of Brep support to determine the radius and center
of a cone( properties shown up in the image image) with circular
base.

Below .NET code snippet can be used :

29 of 33 5/24/2020, 9:13 PM
AutoCAD DevBlog https://adndevblog.typepad.com/autocad/page/3/

[CommandMethod("circularConeRadiusAndCenter")]
public void circularConeRadiusAndCenter()
{
Document doc = Autodesk.AutoCAD.Application
Services.Application.DocumentManager.MdiActiveD
ocument;
Database db = doc.Database;
Editor ed = doc.Editor;

// Ask the user to select a solid


PromptEntityOptions peo = new PromptEntityO
ptions("Select a 3D solid");
peo.SetRejectMessage("\nA 3D solid must be
selected.");
peo.AddAllowedClass(typeof(Solid3d), true);
PromptEntityResult per = ed.GetEntity(peo);

if (per.Status != PromptStatus.OK)
return;

Transaction tr = db.TransactionManager.Star
tTransaction();
using (tr)
{
Solid3d sol = tr.GetObject(per.ObjectI
d, OpenMode.ForRead) as Solid3d;
using (Brep brep = new Brep(sol))
{
//check if base is a circular. If y
es, then determine the center and radius
foreach (Complex cmp in brep.Comple
xes)
{
int edgeCnt = 1;
foreach (Edge edge in brep.Edge
s)
{
ed.WriteMessage("\n --> Edg
e : {0}", edgeCnt++);

30 of 33 5/24/2020, 9:13 PM
AutoCAD DevBlog https://adndevblog.typepad.com/autocad/page/3/

Curve3d edgeCurve = edge.Cu


rve;
if (edgeCurve is ExternalCu
rve3d)
{
ed.WriteMessage("\n Edg
e type : {0}", "ExternalCurve3d");
ExternalCurve3d extCurv
e3d = edgeCurve as ExternalCurve3d;
Curve3d nativeCurve = e
xtCurve3d.NativeCurve;
if (nativeCurve is Circ
ularArc3d)
{
ed.WriteMessage("\n
Native curve type : {0}", "CircularArc3d");
CircularArc3d circA
rc3d = nativeCurve as CircularArc3d;
ed.WriteMessage("\n
radius is " + circArc3d.Radius.ToString());
ed.WriteMessage("\n
center is " + PointToStr(circArc3d.Center));
}
else
{
ed.WriteMessage("\n
Native curve type of cone is not Circular");
return;
}

}
}
}
}
}
private string PointToStr(Point3d point)
{

31 of 33 5/24/2020, 9:13 PM
AutoCAD DevBlog https://adndevblog.typepad.com/autocad/page/3/

return "[" +
point.X.ToString("F2") + ", " +
point.Y.ToString("F2") + ", " +
point.Z.ToString("F2")
+ "]";
}

Posted at 11:04 PM in .NET (https://adndevblog.typepad.com/autocad/net/),


AutoCAD (https://adndevblog.typepad.com/autocad/autocad/), Deepak A S Nadig
(https://adndevblog.typepad.com/autocad/deepak-a-s-nadig/) | Permalink
(https://adndevblog.typepad.com/autocad/2018/04/determine-the-radius-and-
center-of-circular-cone-base-using-net-.html) | Comments (0)
(https://adndevblog.typepad.com/autocad/2018/04/determine-the-radius-and-
center-of-circular-cone-base-using-net-.html#comments)

04/17/2018
Forge NextGen webinars!
(https://adndevblog.typepad.com
/autocad/2018/04/forge-nextgen-
webinars.html)

(https://adndevblog.typepad.com
/.a/6a0167607c2431970b01bb0a04e823970d-pi)

Are you ready to learn about the new technologies that will become
available on the Forge platform?
Then you should not miss these webinars :)

32 of 33 5/24/2020, 9:13 PM
AutoCAD DevBlog https://adndevblog.typepad.com/autocad/page/3/

Date : 26th April 2018


Time : 8.00 AM PST
Duration : 90 minutes
Title : The Future of Making Things on Forge: Sneak Peek at
Forge NextGen (HFDM & App Framework)
Registration Link: https://attendee.gotowebinar.com/register
/8209398405782333955 (https://attendee.gotowebinar.com
/register/8209398405782333955)
Presenter: Lior Gerling, Sr. Product Manager Forge Platform

Date : May 9th 2018


Time : 8.00 AM PST
Duration : 90 minutes
Title : A technical introduction to Forge High Frequency
Data Management (HFDM) SDK and Forge App
Framework
Registration Link: https://attendee.gotowebinar.com/register
/3624195224359611394 (https://attendee.gotowebinar.com/register
/3624195224359611394)
Presenter: Kai Schroeder, Engineering Manager, Forge Platform

Posted at 10:08 PM in Announcements (https://adndevblog.typepad.com/autocad


/announcements/) | Permalink (https://adndevblog.typepad.com/autocad
/2018/04/forge-nextgen-webinars.html) | Comments (0)
(https://adndevblog.typepad.com/autocad/2018/04/forge-nextgen-
webinars.html#comments)

AutoCAD DevBlog (https://adndevblog.typepad.com/autocad/)

33 of 33 5/24/2020, 9:13 PM

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy