ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

AutoCAD 2013 drawings doesnot shown ObjectAR custom class objects

4 REPLIES 4
Reply
Message 1 of 5
nini18110
391 Views, 4 Replies

AutoCAD 2013 drawings doesnot shown ObjectAR custom class objects

I have an c# Application to create a custom objects in AutoCAD 2013 drawings by using unmanaged solution dll(written by using ARX 2013 classes).

After creating an antity nothing has shown up in Drawing .The Drawing was empty but object count shows that There is an object existance in the opened Drawing.

 

Please help me to figure out the issue.

 

I am using hte following code to crete my custom object in C#.

 

 

public

 

 

 

 

 

static void CreateAdim(Assemblies assemblies)

{

 

 

// get the working database for the active document

 

 

Database db = HostApplicationServices.WorkingDatabase;

 

 

// pick two hotspots. Potentially nested in a DDP, or maybe just in the assembly

 

 

tr_adim_item newItem = AdimGetHotSpots();

 

 

tr_adim_item resolvedItem;

 

 

//5.120 if (newItem.hs1 == string.Empty || newItem.hs2 == string.Empty)

 

 

if (newItem.hs1 == null || newItem.hs2 == null || newItem.hs1 == string.Empty || newItem.hs2 == string.Empty) //added watch for null object

 

 

return;

 

 

// see if we can get the part and asmpart ids to ensure they exist

 

 

if (ResolveNestHotSpotNames(assemblies, newItem, out resolvedItem))

{

 

 

// going to do some prompts

 

 

Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;

 

 

// get the axis

 

 

int axis = GetDimAxis();

 

 

if (axis == -1)

 

 

return;

 

 

// get the symbol name for the adim

 

 

string adimName = GetAdimSymbol();

 

 

if (adimName != string.Empty)

{

 

 

string adimDesc = GetDimDescription();

 

 

// get the description for the adim

 

 

if (adimDesc != string.Empty)

{

 

 

// get the plane for it to extend into

 

 

int plane = GetDimPlane(axis);

 

 

if (plane == -1)

 

 

return;

 

 

// set to yellow

 

 

AcGenLib.Layer.LayerColor = Autodesk.AutoCAD.Colors.Color.FromColorIndex(Autodesk.AutoCAD.Colors.ColorMethod.ByAci, 2);

 

 

ObjectId layerId;

 

 

Vector3d norm;

 

 

int face = GetAdimViewport(axis, plane, out layerId, out norm);

 

 

if (face != -1)

{

 

 

// determine what level (how far out it goes)

 

 

int level = GetAdimLevel();

 

 

// returns -1 if the user cancelled

 

 

if (level == -1)

 

 

return;

 

 

Vector3d extLineAng1 = Vector3d.XAxis;

 

 

Vector3d extLineAng2 = Vector3d.XAxis;

 

 

bool bHorz = false;

 

 

// get the normal based on the axis they selected

 

 

switch (axis)

{

 

 

case 0:

 

 

if (plane == TRNEDDPAdimMgd.kViewcode_Back)

{

extLineAng1 =

 

new Vector3d(0, 1, 0);

extLineAng2 =

 

new Vector3d(0, 1, 0);

bHorz =

 

true;

}

 

 

else if (plane == TRNEDDPAdimMgd.kViewcode_Front)

{

extLineAng1 =

 

new Vector3d(0, -1, 0);

extLineAng2 =

 

new Vector3d(0, -1, 0);

bHorz =

 

true;

}

 

 

else if (plane == TRNEDDPAdimMgd.kViewcode_Top)

{

extLineAng1 =

 

new Vector3d(0, 0, 1);

extLineAng2 =

 

new Vector3d(0, 0, 1);

bHorz =

 

true;

}

 

 

else if (plane == TRNEDDPAdimMgd.kViewcode_Bottom)

{

extLineAng1 =

 

new Vector3d(0, 0, -1);

extLineAng2 =

 

new Vector3d(0, 0, -1);

bHorz =

 

true;

}

 

 

break;

 

 

case 1:

 

 

if (plane == (int)TRNEDDPAdimMgd.kViewcode_Right)

{

extLineAng1 =

 

new Vector3d(1, 0, 0);

extLineAng2 =

 

new Vector3d(1, 0, 0);

bHorz =

 

false;

}

 

 

else if (plane == (int)TRNEDDPAdimMgd.kViewcode_Left)

{

extLineAng1 =

 

new Vector3d(-1, 0, 0);

extLineAng2 =

 

new Vector3d(-1, 0, 0);

bHorz =

 

false;

}

 

 

else if (plane == (int)TRNEDDPAdimMgd.kViewcode_Top)

{

extLineAng1 =

 

new Vector3d(0, 0, 1);

extLineAng2 =

 

new Vector3d(0, 0, 1);

bHorz =

 

true;

}

 

 

else if (plane == (int)TRNEDDPAdimMgd.kViewcode_Bottom)

{

extLineAng1 =

 

new Vector3d(0, 0, -1);

extLineAng2 =

 

new Vector3d(0, 0, -1);

bHorz =

 

true;

}

 

 

break;

 

 

case 2:

 

 

if (plane == (int)TRNEDDPAdimMgd.kViewcode_Right)

{

extLineAng1 =

 

new Vector3d(1, 0, 0);

extLineAng2 =

 

new Vector3d(1, 0, 0);

bHorz =

 

false;

}

 

 

else if (plane == (int)TRNEDDPAdimMgd.kViewcode_Left)

{

extLineAng1 =

 

new Vector3d(-1, 0, 0);

extLineAng2 =

 

new Vector3d(-1, 0, 0);

bHorz =

 

false;

}

 

 

else if (plane == (int)TRNEDDPAdimMgd.kViewcode_Back)

{

extLineAng1 =

 

new Vector3d(0, 1, 0);

extLineAng2 =

 

new Vector3d(0, 1, 0);

bHorz =

 

false;

}

 

 

else if (plane == (int)TRNEDDPAdimMgd.kViewcode_Front)

{

extLineAng1 =

 

new Vector3d(0, -1, 0);

extLineAng2 =

 

new Vector3d(0, -1, 0);

bHorz =

 

false;

}

 

 

break;

}

 

 

using (Transaction trans = db.TransactionManager.StartTransaction())

{

 

 

using (BlockTable bt = trans.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable)

{

 

 

using (BlockTableRecord modelSpace =

trans.GetObject(bt[

 

BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord)

{

 

 

Point3d ecsLinePt1;

 

 

Point3d wLinePt1;

 

 

Point3d ecsLinePt2;

 

 

Point3d wLinePt2;

 

 

// transform the hot spot points based on the axis they chose

ecsLinePt1 = newItem.pt1.TransformBy(

 

Matrix3d.WorldToPlane(norm));

ecsLinePt2 = newItem.pt2.TransformBy(

 

Matrix3d.WorldToPlane(norm));

 

 

// if its supposed to be horizontal, make sure you set the x,y coords right

 

 

if (bHorz)

ecsLinePt2 =

 

new Point3d(ecsLinePt2.X, ecsLinePt1.Y, ecsLinePt1.Z);

 

 

else

ecsLinePt2 =

 

new Point3d(ecsLinePt1.X, ecsLinePt2.Y, ecsLinePt1.Z);

 

 

// now that the coords are right put them back into world coords

wLinePt1 = ecsLinePt1.TransformBy(

 

Matrix3d.PlaneToWorld(norm));

wLinePt2 = ecsLinePt2.TransformBy(

 

Matrix3d.PlaneToWorld(norm));

 

 

double dimScale = db.Dimscale;

 

 

double gap = 0.1800 * dimScale;

 

 

double offset = 0.0625 * dimScale;

 

 

double txtHgt = 0.1 * dimScale;

 

 

// transform the line points into plane coords

ecsLinePt1 = wLinePt1.TransformBy(

 

Matrix3d.WorldToPlane(norm));

ecsLinePt2 = wLinePt2.TransformBy(

 

Matrix3d.WorldToPlane(norm));

 

 

int tmpLevel = level;

 

 

if (level == 99)

tmpLevel = 10;

 

 

// determine how far out the line pts are

 

 

// supposed to be relative to the hot spot

 

 

Point3d tmpPt = wLinePt1.TransformBy(Matrix3d.Displacement(new Vector3d(0, 1 * .11, 0)));

 

 

Point3d wEp13d = wLinePt1 + (extLineAng1 * (txtHgt * (tmpLevel + 1)));

 

 

Point3d wEp23d = wLinePt2 + (extLineAng2 * (txtHgt * (tmpLevel + 1)));

 

 

// draw the line

 

 

LineSegment3d tmpEdgeLine = new LineSegment3d(wEp13d, wEp23d);

 

 

TRNEDDPAdimMgd mg = new TRNEDDPAdimMgd();

 

 

 

// get the midpoint which

 

 

// is where we'll put the text

 

 

Point3d txtEp1 = tmpEdgeLine.MidPoint;

mg.Normal = norm;

mg.TextPt = txtEp1;

 

 

// set text for the hot spot names

mg.DimFrom = resolvedItem.hs1;

mg.DimTo = resolvedItem.hs2;

 

 

// set text for the symbol

mg.DimSymbol = adimName;

 

 

// set text for the desc

mg.DimDescr = adimDesc;

mg.AxisOn = axis;

mg.DimPlane = plane;

mg.ViewCode = face;

mg.Level = level;

 

 

// set the points that will create the

 

 

// line that is parallel to the hot spot

mg.LinePt1 = wLinePt1;

mg.LinePt2 = wLinePt2;

 

 

// set the pts where the hot spots are

mg.StartPt = wEp13d;

mg.EndPt = wEp23d;

 

 

if (layerId != ObjectId.Null)

mg.LayerId = layerId;

 

 

// add this to model space

modelSpace.AppendEntity(mg);

 

 

// notify the transaction

trans.AddNewlyCreatedDBObject(mg,

 

true);

 

 

// save changes

trans.Commit();

}

}

}

}

}

}

 

 

else

{

ed.WriteMessage(

 

"\nInvalid Symbol Name.\n\nAdim not created");

 

 

return;

}

}

}

 

 

 

I am attaching the cpp files which creates dll for unmanaged solution with ARX classes.

 

Kindly help me soon to resolve the issue.

 

 

4 REPLIES 4
Message 2 of 5
owenwengerd
in reply to: nini18110

I don't think you'll have much luck getting help unless you post something easier to digest. If you need someone to debug an entire application, you're better served to hire a consultant. If you can distill your question down to a short post with just relevant code, you're more likely to get assistance here.

--
Owen Wengerd
ManuSoft
Message 3 of 5
maisoui
in reply to: owenwengerd

I would add that you have to use the right forum (.NET), instead of ObjectARX C++.

--
Jonathan
Message 4 of 5
nini18110
in reply to: nini18110

Okey let me simplify my issue .

 

 

The problem is, when I create a new object as shown below and append the new object to the database within a transaction.

 I am not getting any error or exception while creating an object . but after creating the object, it is not shown in AUtoCAD 2013 drawing window.

When i check the drawing details it showing that the specified object is created .is there any problem in rendering the object? 

 

 

using (Transaction trans = db.TransactionManager.StartTransaction())

{

 using (BlockTable bt = trans.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable)

{

 using (BlockTableRecord modelSpace =

trans.GetObject(bt[

BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord)

{

..................................//some manipulation to draw the line and properties

 

TRNEDDPAdimMgd mg = new TRNEDDPAdimMgd();

 

.............//other codeto create object properties text and desc and so etc.

 

if (layerId != ObjectId.Null)

mg.LayerId = layerId;

modelSpace.AppendEntity(mg);

trans.AddNewlyCreatedDBObject(mg,true);

trans.Commit();

}}}}}}

else

{

ed.WriteMessage(

"\nInvalid Symbol Name.\n\nAdim not created");

return;

}}}

 

 

 

I dont understand the exact problem . Please let me know any idea on this.

I even verified the compiler versions for my project it has 4.0 .net framework and vs2010 64 bit.

Message 5 of 5
owenwengerd
in reply to: nini18110

You're going to have to debug your application to determine where things go wrong. The code you show is not helpful.

--
Owen Wengerd
ManuSoft

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost