青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

C++ Programmer's Cookbook

{C++ 基礎} {C++ 高級} {C#界面,C++核心算法} {設計模式} {C#基礎}

很好的arx學習代碼(.net版)

using ?System?;
using ?Autodesk.AutoCAD.Runtime?;
using ?Autodesk.AutoCAD.ApplicationServices;
using ?Autodesk.AutoCAD.DatabaseServices;
using ?Autodesk.AutoCAD.Geometry;
using ?Autodesk.AutoCAD.Colors;
using ?Autodesk.AutoCAD.EditorInput;

[assembly:?CommandClass(
typeof (ClassLibrary.Class))]

namespace ?ClassLibrary
{
????
/// ? <summary>
????
/// ?Summary?description?for?Class.
????
/// ? </summary>

???? public ? class ?Class
????
{
????????
public ?Class()
????????
{
????????????
//
????????????
// ?TODO:?Add?constructor?logic?here
????????????
//
????????}

????????
// This?function?returns?the?ObjectId?for?the?BlockTableRecord?called?"EmployeeBlock",
????????
// creating?it?if?necessary.??The?block?contains?three?entities?-?circle,?text?
????????
// and?ellipse.
???????? public ?ObjectId?CreateEmployeeDefinition()?
????????
{?
????????????ObjectId?newBtrId?
= ? new ?ObjectId();? // The?return?value?for?this?function
????????????Database?db? = ?HostApplicationServices.WorkingDatabase;? // save?some?space
????????????Transaction?trans? = ?db.TransactionManager.StartTransaction();? // begin?the?transaction
????????????Editor?ed? = ?Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;?
????????????
????????????
try ?
????????????
{?
????????????????
// Now,?drill?into?the?database?and?obtain?a?reference?to?the?BlockTable
????????????????BlockTable?bt? = ?(BlockTable)trans.GetObject(db.BlockTableId,?OpenMode.ForWrite);?
????????????????
if ?((bt.Has( " EmployeeBlock " )))?
????????????????
{?
????????????????????newBtrId?
= bt[ " EmployeeBlock " ];
????????????????}
?
????????????????
else ?
????????????????
{?
????????????????????Point3d?center?
= ? new ?Point3d( 10 ,? 10 ,? 0 );? // ?convenient?declaration
????????????????????
// ??Declare?and?define?the?entities?we?want?to?add:
????????????????????
// Circle:
????????????????????Circle?circle? = ? new ?Circle(center,?Vector3d.ZAxis,? 2 );?
????????????????????
// Text:
????????????????????
// MText?text?=?new?MText();?
????????????????????
// text.Contents?=?"Earnest?Shackleton";?
????????????????????
// text.Location?=?center;?
????????????????
????????????????????
// Attribute?Definition
????????????????????AttributeDefinition?text? = ? new ?AttributeDefinition(center,? " NoName " ,? " Name: " ,? " Enter?Name " ,?db.Textstyle);
????????????????????text.ColorIndex?
= ? 2 ;

????????????????????
// Ellipse:
????????????????????Ellipse?ellipse? = ? new ?Ellipse(center,?Vector3d.ZAxis,? new ?Vector3d( 3 ,? 0 ,? 0 ),? 0.5 ,? 0 ,? 0 );?

????????????????????
// Next,?create?a?layer?with?the?helper?function,?and?assign
????????????????????
// the?layer?to?our?entities.
????????????????????ObjectId?empId? = ?CreateLayer();?
????????????????????text.LayerId?
= ?empId;?
????????????????????circle.LayerId?
= ?empId;?
????????????????????ellipse.LayerId?
= ?empId;?
????????????????????
// Set?the?color?for?each?entity?irrespective?of?the?layer's?color.
????????????????????text.ColorIndex? = ? 2 ;?
????????????????????circle.ColorIndex?
= ? 1 ;?
????????????????????ellipse.ColorIndex?
= ? 3 ;?

????????????????????
// Create?a?new?block?definition?called?EmployeeBlock
????????????????????BlockTableRecord?newBtr? = ? new ?BlockTableRecord();?
????????????????????newBtr.Name?
= ? " EmployeeBlock " ;?
????????????????????newBtrId?
= ?bt.Add(newBtr);? // Add?the?block,?and?set?the?id?as?the?return?value?of?our?function
????????????????????trans.AddNewlyCreatedDBObject(newBtr,? true );? // Let?the?transaction?know?about?any?object/entity?you?add?to?the?database!
????????????????????
????????????????????newBtr.AppendEntity(circle);?
// Append?our?entities
????????????????????newBtr.AppendEntity(text);?
????????????????????newBtr.AppendEntity(ellipse);?
????????????????????trans.AddNewlyCreatedDBObject(circle,?
true );? // Again,?let?the?transaction?know?about?our?newly?added?entities.
????????????????????trans.AddNewlyCreatedDBObject(text,? true );?
????????????????????trans.AddNewlyCreatedDBObject(ellipse,?
true );?
????????????????????????????????????????
????????????????}
?
????????????????trans.Commit();?
// All?done,?no?errors???Go?ahead?and?commit!
????????????}
?
????????????
catch ?
????????????
{?????????????????
????????????????ed.WriteMessage(
" Error?Creating?Employee?Block " );
????????????}
?
????????????
finally ?
????????????
{?
????????????????trans.Dispose();?
????????????}
?
????????????
// CreateDivision();? // Create?the?Employee?Division?dictionaries.
???????????? return ?newBtrId;?
????????}

????????

????????
// This?function?creates?a?new?BlockReference?to?the?"EmployeeBlock"?object,
????????
// and?adds?it?to?ModelSpace.
???????? public ?ObjectId?CreateEmployee( string ?name,? string ?division,? double ?salary,?Point3d?pos)?
????????
{?
????????????Database?db?
= ?HostApplicationServices.WorkingDatabase;?
????????????Transaction?trans?
= ?db.TransactionManager.StartTransaction();?
????????????
try ?
????????????
{?

????????????????BlockTable?bt?
= ?(BlockTable)(trans.GetObject(db.BlockTableId,?OpenMode.ForWrite));?
????????????????BlockTableRecord?btr?
= (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace],?OpenMode.ForWrite);
????????????????
// Create?the?block?referenceuse?the?return?from?CreateEmployeeDefinition?directly!
????????????????BlockReference?br? = ? new ?BlockReference(pos,?CreateEmployeeDefinition());?
????????
// ????????btr.AppendEntity(br);? // Add?the?reference?to?ModelSpace
????????
// ????????trans.AddNewlyCreatedDBObject(br,?true);? // Let?the?transaction?know?about?it

????????????????AttributeReference?attRef?
= ? new ?AttributeReference();?
????????????????
// Iterate?the?employee?block?and?find?the?attribute?definition
????????????????BlockTableRecord?empBtr? = ?(BlockTableRecord)trans.GetObject(bt[ " EmployeeBlock " ],?OpenMode.ForRead);?
????????????????
foreach ?(ObjectId?id? in ?empBtr)?
????????????????
{?
????????????????????Entity?ent?
= ?(Entity)trans.GetObject(id,?OpenMode.ForRead,? false );?
????????????????????
// Use?it?to?open?the?current?object!?
???????????????????? if ?(ent? is ?AttributeDefinition)?? // We?use?.NET's?RTTI?to?establish?type.
???????????????????? {?
????????????????????????
// Set?the?properties?from?the?attribute?definition?on?our?attribute?reference
????????????????????????AttributeDefinition?attDef? = ?((AttributeDefinition)(ent));?
????????????????????????attRef.SetPropertiesFrom(attDef);?
????????????????????????attRef.Position?
= ? new ?Point3d(attDef.Position.X? + ?br.Position.X,?attDef.Position.Y? + ?br.Position.Y,?attDef.Position.Z? + ?br.Position.Z);?
????????????????????????attRef.Height?
= ?attDef.Height;?
????????????????????????attRef.Rotation?
= ?attDef.Rotation;?
????????????????????????attRef.Tag?
= ?attDef.Tag;?
????????????????????????attRef.TextString?
= ?name;?
????????????????????}
?
????????????????}
?
????????????????
// Add?the?reference?to?ModelSpace
????????????????btr.AppendEntity(br);?
????????????????
// Add?the?attribute?reference?to?the?block?reference
????????????????br.AttributeCollection.AppendAttribute(attRef);?
????????????????
// let?the?transaction?know
????????????????trans.AddNewlyCreatedDBObject(attRef,? true );?
????????????????trans.AddNewlyCreatedDBObject(br,?
true );

????????????????
// Create?the?custom?per-employee?data
????????????????Xrecord?xRec? = ?? new ?Xrecord();
????????????????
// We?want?to?add?'Name',?'Salary'?and?'Division'?information.??Here?is?how:
????????????????xRec.Data? = ? new ?ResultBuffer(?
????????????????????
new ?TypedValue(( int )DxfCode.Text,?name),?
????????????????????
new ?TypedValue(( int )DxfCode.Real,?salary),?
????????????????????
new ?TypedValue(( int )DxfCode.Text,?division));

????????????????
// Next,?we?need?to?add?this?data?to?the?'Extension?Dictionary'?of?the?employee.
????????????????br.CreateExtensionDictionary();
????????????????DBDictionary?brExtDict??
= ?(DBDictionary)trans.GetObject(br.ExtensionDictionary,?OpenMode.ForWrite,? false );
????????????????brExtDict.SetAt(
" EmployeeData " ,?xRec);? // Set?our?XRecord?in?the?dictionary?at?'EmployeeData'.
????????????????trans.AddNewlyCreatedDBObject(xRec,? true );

????????????????trans.Commit();?
????????????????
return ?br.ObjectId;
????????????}
?
????????????
finally ?
????????????
{?
????????????????trans.Dispose();?
????????????}
?
????????}

?????????
????????
// This?function?returns?the?objectId?for?the?"EmployeeLayer",?creating?it?if?necessary.
???????? public ?ObjectId?CreateLayer()?
????????
{?
????????????ObjectId?layerId;?
????????????Database?db?
= ?HostApplicationServices.WorkingDatabase;?
????????????Transaction?trans?
= ?db.TransactionManager.StartTransaction();?
????????????
// Get?the?layer?table?first
????????????LayerTable?lt? = ?(LayerTable)trans.GetObject(db.LayerTableId,?OpenMode.ForWrite);?
????????????
// Check?if?EmployeeLayer?exists
????????????
????????????
if ?(lt.Has( " EmployeeLayer " ))?
????????????
{?
????????????????layerId?
= ?lt[ " EmployeeLayer " ];
????????????}
?
????????????
else ?
????????????
{?
????????????????
// If?not,?create?the?layer?here.
????????????????LayerTableRecord?ltr? = ? new ?LayerTableRecord();?
????????????????ltr.Name?
= ? " EmployeeLayer " ;? // ?Set?the?layer?name
????????????????ltr.Color? = ?Color.FromColorIndex(ColorMethod.ByAci,? 2 );?
????????????????layerId?
= ?lt.Add(ltr);?
????????????????trans.AddNewlyCreatedDBObject(ltr,?
true );?
????????????}
?
????????????trans.Commit();?
????????????trans.Dispose();?
????????????
return ?layerId;?
????????}


????????
public ?ObjectId?CreateDivision( string ?division,? string ?manager)
????????
{
????????????Database?db?
= ?HostApplicationServices.WorkingDatabase;
????????????Transaction?trans?
= ?db.TransactionManager.StartTransaction();?

????????????
try
????????????
{
????????????????
// First,?get?the?NOD
????????????????DBDictionary?NOD? = ?(DBDictionary)trans.GetObject(db.NamedObjectsDictionaryId,?OpenMode.ForWrite);
????????????????
// Define?a?corporate?level?dictionary
????????????????DBDictionary?acmeDict;
????????????????
try
????????????????
{
????????????????????
// Just?throw?if?it?doesn't?existdo?nothing?else
????????????????????acmeDict? = ?(DBDictionary)trans.GetObject(NOD.GetAt( " ACME_DIVISION " ),?OpenMode.ForRead);
????????????????}

????????????????
catch
????????????????
{
????????????????????
// Doesn't?exist,?so?create?one,?and?set?it?in?the?NOD?
????????????????????acmeDict? = ? new ?DBDictionary();
????????????????????NOD.SetAt(
" ACME_DIVISION " ,?acmeDict);
????????????????????trans.AddNewlyCreatedDBObject(acmeDict,?
true );
????????????????}


????????????????
// Now?get?the?division?we?want?from?acmeDict
????????????????DBDictionary?divDict;
????????????????
try
????????????????
{
????????????????????divDict?
= ?(DBDictionary)trans.GetObject(acmeDict.GetAt(division),?OpenMode.ForWrite);
????????????????}

????????????????
catch
????????????????
{
????????????????????divDict?
= ? new ?DBDictionary();
????????????????????
// Division?doesn't?exist,?create?one
????????????????????acmeDict.UpgradeOpen();
????????????????????acmeDict.SetAt(division,?divDict);
????????????????????trans.AddNewlyCreatedDBObject(divDict,?
true );
????????????????}


????????????????
// Now?get?the?manager?info?from?the?division
????????????????
// We?need?to?add?the?name?of?the?division?supervisor.??We'll?do?this?with?another?XRecord.
????????????????Xrecord?mgrXRec;
????????????????
try
????????????????
{
????????????????????mgrXRec?
= ?(Xrecord)trans.GetObject(divDict.GetAt( " Department?Manager " ),?OpenMode.ForWrite);
????????????????}

????????????????
catch
????????????????
{
????????????????????mgrXRec?
= ? new ?Xrecord();
????????????????????mgrXRec.Data?
= ? new ?ResultBuffer( new ?TypedValue(( int )DxfCode.Text,?manager));
????????????????????divDict.SetAt(
" Department?Manager " ,?mgrXRec);
????????????????????trans.AddNewlyCreatedDBObject(mgrXRec,?
true );
????????????????}


????????????????trans.Commit();
????????????????
// Return?the?department?manager?XRecord
???????????????? return ?mgrXRec.ObjectId;

????????????}

????????????
finally
????????????
{
????????????????trans.Dispose();
????????????}

????????}


????????[CommandMethod(
" EMPLOYEECOUNT " )]
????????
public ? void ?EmployeeCount()
????????
{
????????????Database?db?
= ?HostApplicationServices.WorkingDatabase;
????????????Transaction?trans?
= ?db.TransactionManager.StartTransaction();?? // Start?the?transaction.
???????????? int ?nEmployeeCount?? = ? 0 ;
????????????
try
????????????
{
????????????????
// First,?get?at?the?BlockTable,?and?the?ModelSpace?BlockTableRecord
????????????????BlockTable?bt? = ?(BlockTable)trans.GetObject(db.BlockTableId,?OpenMode.ForRead);
????????????????BlockTableRecord?btr?
= ?(BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace],?OpenMode.ForRead);
????????????????
// Now,?we?need?to?be?able?to?print?to?the?commandline.??Here?is?an?object?which?will?help?us:
????????????????Editor?ed? = ?Application.DocumentManager.MdiActiveDocument.Editor;

????????????????
// Now,?here?is?the?fun?part.??This?is?where?we?iterate?through?ModelSpace:
???????????????? foreach ?(ObjectId?id? in ?btr)
????????????????
{
????????????????????Entity?ent?
= ?(Entity)trans.GetObject(id,?OpenMode.ForRead,? false );?? // Use?it?to?open?the?current?object!
???????????????????? if ?(ent.GetType()? == ? typeof (BlockReference))? // We?use?.NET's?RTTI?to?establish?type.
???????????????????? {
????????????????????????nEmployeeCount?
+= ? 1 ;
????????????????????}

????????????????}


????????????????ed.WriteMessage(
" Employees?Found:? " ? + ?nEmployeeCount.ToString());
????????????????trans.Commit();
????????????}

????????????
finally
????????????
{
????????????????trans.Dispose();
????????????}

????????}


????????
// We?want?a?command?which?will?go?through?and?list?all?the?relevant?employee?data.
???????? public ? static ? void ?ListEmployee(ObjectId?employeeId,? ref ? string []?saEmployeeList)?
????????
{?
????????????
int ?nEmployeeDataCount? = ? 0 ;?
????????????Database?db?
= ?HostApplicationServices.WorkingDatabase;?
????????????Transaction?trans?
= ?db.TransactionManager.StartTransaction();? // Start?the?transaction
???????????? try ?
????????????
{?
????????????????Entity?ent?
= ?(Entity)trans.GetObject(employeeId,?OpenMode.ForRead,? false );? // Use?it?to?open?the?current?object!
???????????????? if ?(ent.GetType()? == ? typeof (BlockReference))? // We?use?.NET's?RTTI?to?establish?type.
???????????????? {?
????????????????????
// Not?all?BlockReferences?will?have?our?employee?data,?so?we?must?make?sure?we?can?handle?failure
???????????????????? bool ?bHasOurDict? = ? true ;?
????????????????????Xrecord?EmployeeXRec?
= ? null ;?
????????????????????
try ?
????????????????????
{?
????????????????????????BlockReference?br?
= ?(BlockReference)ent;?
????????????????????????DBDictionary?extDict?
= ?(DBDictionary)trans.GetObject(br.ExtensionDictionary,?OpenMode.ForRead,? false );?
????????????????????????EmployeeXRec?
= ?(Xrecord)trans.GetObject(extDict.GetAt( " EmployeeData " ),?OpenMode.ForRead,? false );?
????????????????????}
?
????????????????????
catch ?
????????????????????
{?
????????????????????????bHasOurDict?
= ? false ;? // Something?bad?happenedour?dictionary?and/or?XRecord?is?not?accessible
????????????????????}
?

????????????????????
if ?(bHasOurDict)? // If?obtaining?the?Extension?Dictionary,?and?our?XRecord?is?successful
???????????????????? {?

????????????????????????
// ?allocate?memory?for?the?list
????????????????????????saEmployeeList? = ? new ?String[ 4 ];

????????????????????????TypedValue?resBuf?
= ?EmployeeXRec.Data.AsArray()[ 0 ];?
????????????????????????saEmployeeList.SetValue(
string .Format( " {0}\n " ,?resBuf.Value),?nEmployeeDataCount);?
????????????????????????nEmployeeDataCount?
+= ? 1 ;?
????????????????????????resBuf?
= ?EmployeeXRec.Data.AsArray()[ 1 ];?
????????????????????????saEmployeeList.SetValue(
string .Format( " {0}\n " ,?resBuf.Value),?nEmployeeDataCount);?
????????????????????????nEmployeeDataCount?
+= ? 1 ;?
????????????????????????resBuf?
= ?EmployeeXRec.Data.AsArray()[ 2 ];?
????????????????????????
string ?str? = ?( string )resBuf.Value;?
????????????????????????saEmployeeList.SetValue(
string .Format( " {0}\n " ,?resBuf.Value),?nEmployeeDataCount);?
????????????????????????nEmployeeDataCount?
+= ? 1 ;?
????????????????????????DBDictionary?NOD?
= ?(DBDictionary)trans.GetObject(db.NamedObjectsDictionaryId,?OpenMode.ForRead,? false );?
????????????????????????DBDictionary?acmeDict?
= ?(DBDictionary)trans.GetObject(NOD.GetAt( " ACME_DIVISION " ),?OpenMode.ForRead);?
????????????????????????DBDictionary?salesDict?
= ?(DBDictionary)trans.GetObject(acmeDict.GetAt(( string )EmployeeXRec.Data.AsArray()[ 2 ].Value),?OpenMode.ForRead);?
????????????????????????Xrecord?salesXRec?
= ?(Xrecord)trans.GetObject(salesDict.GetAt( " Department?Manager " ),?OpenMode.ForRead);?
????????????????????????resBuf?
= ?salesXRec.Data.AsArray()[ 0 ];?
????????????????????????saEmployeeList.SetValue(
string .Format( " {0}\n " ,?resBuf.Value),?nEmployeeDataCount);?
????????????????????????nEmployeeDataCount?
+= ? 1 ;?
????????????????????}
?
????????????????}
?
????????????????trans.Commit();?
????????????}
?
????????????
finally ?
????????????
{?
????????????????trans.Dispose();?
????????????}
?
????????}
?

????
????????[CommandMethod(
" PRINTOUTEMPLOYEE " )]?
????????
public ? static ?? void ?PrintoutEmployee()?
????????
{?
????????????Editor?ed?
= ?Application.DocumentManager.MdiActiveDocument.Editor;?
????????????Database?db?
= ?HostApplicationServices.WorkingDatabase;?
????????????Transaction?trans?
= ?db.TransactionManager.StartTransaction();?
????????????
try ?
????????????
{?
????????????????BlockTable?bt?
= ?(BlockTable)trans.GetObject(HostApplicationServices.WorkingDatabase.BlockTableId,?OpenMode.ForRead);?
????????????????BlockTableRecord?btr?
= ?(BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace],?OpenMode.ForRead);?
????????????????
foreach ?(ObjectId?id? in ?btr)?
????????????????
{?
????????????????????Entity?ent?
= ?(Entity)trans.GetObject(id,?OpenMode.ForRead,? false );?
????????????????????
if ?(ent? is ?BlockReference)?
????????????????????
{?
????????????????????????
string []?saEmployeeList? = ? null ;
????????????????
????????????????????????ListEmployee(id,?
ref ?saEmployeeList);?
????????????????????????
if ?((saEmployeeList.Length? == ? 4 ))?
????????????????????????
{?
????????????????????????????ed.WriteMessage(
" Employee?Name:?{0} " ,?saEmployeeList[ 0 ]);?
????????????????????????????ed.WriteMessage(
" Employee?Salary:?{0} " ,?saEmployeeList[ 1 ]);?
????????????????????????????ed.WriteMessage(
" Employee?Division:?{0} " ,?saEmployeeList[ 2 ]);?
????????????????????????????ed.WriteMessage(
" Division?Manager:?{0} " ,?saEmployeeList[ 3 ]);?
????????????????????????}
?
????????????????????}
?
????????????????}
?
????????????}
?
????????????
finally ?
????????????
{?
????????????}
?????
????????}


????????[CommandMethod(
" CREATE " )]?
????????
public ? void ?CreateEmployee()?
????????
{?
????????????Database?db?
= ?HostApplicationServices.WorkingDatabase;?
????????????Editor?ed?
= ?Application.DocumentManager.MdiActiveDocument.Editor;?
????????????Transaction?trans?
= ?db.TransactionManager.StartTransaction();?
????????????
try ?
????????????
{?
????????????????
string ?empName? = ?? " Earnest?Shackleton " ;
????????????????
string ?divName? = ?? " Sales " ;?
????????????????
double ?salary? = ? new ? double ();?
????????????????salary?
= ? 10000 ;?
????????????????Point3d?position?
= ? new ?Point3d( 0 ,? 0 ,? 0 );?
????????????????
bool ?gotPosition? = ? new ? bool ();?
????????????????
// boolean?to?check?if?a?point?has?been?entered
????????????????gotPosition? = ? false ;

????????????????
// Prompts?for?each?employee?detail
????????????????PromptStringOptions?prName? = ? new ?PromptStringOptions( " Enter?Employee?Name?< " ? + ?empName? + ? " > " );?
????????????????PromptStringOptions?prDiv?
= ? new ?PromptStringOptions( " Enter?Employee?Division?< " ? + ?divName? + ? " > " );?
????????????????PromptDoubleOptions?prSal?
= ? new ?PromptDoubleOptions( " Enter?Employee?Salary?< " ? + ?salary? + ? " > " );?
????????????????PromptPointOptions?prPos?
= ? new ?PromptPointOptions( " Enter?Employee?Position?or " );

????????????????
// Add?keywords?when?prompting?for?position
????????????????prPos.Keywords.Add( " Name " );?
????????????????prPos.Keywords.Add(
" Division " );?
????????????????prPos.Keywords.Add(
" Salary " );?
????????????????
// Set?conditions?for?prompting
????????????????prPos.AllowNone? = ? false ;? // Do?not?allow?null?values

????????????????
// prompt?results
????????????????PromptResult?prNameRes;?
????????????????PromptResult?prDivRes;?
????????????????PromptDoubleResult?prSalRes;?
????????????????PromptPointResult?prPosRes;

????????????????
// Loop?to?get?employee?details.?Exit?the?loop?when?positon?is?entered
???????????????? while ?( ! gotPosition)?
????????????????
{?
????????????????????
// Prompt?for?position
????????????????????prPosRes? = ?ed.GetPoint(prPos);?
????????????????????
// Got?a?point
???????????????????? if ?(prPosRes.Status? == ?PromptStatus.OK)?
????????????????????
{?
????????????????????????gotPosition?
= ? true ;?
????????????????????????position?
= ?prPosRes.Value;?
????????????????????}
?
????????????????????
else ? if ?(prPosRes.Status? == ?PromptStatus.Keyword)? // Got?a?keyword
???????????????????? {?
????????????????????????
// Name?keyword?entered
???????????????????????? if ?(prPosRes.StringResult? == ? " Name " )?
????????????????????????
{?
????????????????????????????
// Get?employee?name
????????????????????????????prName.AllowSpaces? = ? true ;?
????????????????????????????prNameRes?
= ?ed.GetString(prName);?
????????????????????????????
if ?(prNameRes.Status? != ?PromptStatus.OK)?
????????????????????????????
{?
????????????????????????????????
return ;?
????????????????????????????}
?
????????????????????????????
// we?got?the?employee?name?successfully
???????????????????????????? if ?(prNameRes.StringResult? != ? "" )?
????????????????????????????
{?
????????????????????????????????empName?
= ?prNameRes.StringResult;?
????????????????????????????}
?
????????????????????????}

?
????????????????????????
// Division?keyword?entered
???????????????????????? if ?(prPosRes.StringResult? == ? " Division " )?
????????????????????????
{?

????????????????????????????
// Get?employee?division
????????????????????????????prDiv.AllowSpaces? = ? true ;?
????????????????????????????prDivRes?
= ?ed.GetString(prDiv);?
????????????????????????????
if ?(prDivRes.Status? != ?PromptStatus.OK)?
????????????????????????????
{?
????????????????????????????????
return ;?
????????????????????????????}
?
????????????????????????????
if ?(prDivRes.StringResult? != ? "" )?
????????????????????????????
{?
????????????????????????????????divName?
= ?prDivRes.StringResult;?
????????????????????????????}
?
????????????????????????}
? // ?Division

????????????????????????
// ?Salary?keyword?entered
???????????????????????? if ?(prPosRes.StringResult? == ? " Salary " )?
????????????????????????
{?
????????????????????????????
// Get?employee?salary
????????????????????????????prSal.AllowNegative? = ? false ;?
????????????????????????????prSal.AllowNone?
= ? true ;?
????????????????????????????prSal.AllowZero?
= ? false ;?
????????????????????????????prSalRes?
= ?ed.GetDouble(prSal);?
????????????????????????????
if ?(prSalRes.Status? != ?PromptStatus.OK? & ?prSalRes.Status? != ?PromptStatus.None)?
????????????????????????????
{?
????????????????????????????????
return ;?
????????????????????????????}
?
????????????????????????????
if ?(prSalRes.Status? != ?PromptStatus.None)?
????????????????????????????
{?
????????????????????????????????salary?
= ?prSalRes.Value;?
????????????????????????????}
?
????????????????????????}
? // ?Salary
????????????????????}
?
????????????????????
else ?
????????????????????
{?
????????????????????????
// ?Error?in?getting?a?point
????????????????????????ed.WriteMessage( " ***Error?in?getting?a?point,?exiting!!*** " ? + ? " \r\n " );?
????????????????????????
return ;?
????????????????????}
?? // ?If?got?a?point
????????????????}


????????????????
// Create?the?Employee
????????????????CreateEmployee(empName,?divName,?salary,?position);

????????????????
string ?manager? = ? "" ;
????????????????
// Now?create?the?division?
????????????????
// Pass?an?empty?string?for?manager?to?check?if?it?already?exists
????????????????Xrecord?depMgrXRec;?
????????????????ObjectId?xRecId;?
????????????????xRecId?
= ?CreateDivision(divName,?manager);?
????????????????
// Open?the?department?manager?XRecord
????????????????depMgrXRec? = ?(Xrecord)trans.GetObject(xRecId,?OpenMode.ForRead);?
????????????????TypedValue[]?typedVal?
= ?depMgrXRec.Data.AsArray();
????????????????
foreach ?(TypedValue?val? in ?typedVal)?
????????????????
{?
????????????????????
string ?str;?
????????????????????str?
= ?( string )val.Value;?
????????????????????
if ?(str? == ? "" )?
????????????????????
{?
????????????????????????
// Manager?was?not?set,?now?set?it
????????????????????????
// ?Prompt?for??manager?name?first
????????????????????????ed.WriteMessage( " \r\n " );?
????????????????????????PromptStringOptions?prManagerName?
= ? new ?PromptStringOptions( " No?manager?set?for?the?division!?Enter?Manager?Name " );?
????????????????????????prManagerName.AllowSpaces?
= ? true ;?
????????????????????????PromptResult?prManagerNameRes?
= ?ed.GetString(prManagerName);?
????????????????????????
if ?(prManagerNameRes.Status? != ?PromptStatus.OK)?
????????????????????????
{?
????????????????????????????
return ;?
????????????????????????}
?
????????????????????????
// Set?a?manager?name
????????????????????????depMgrXRec.Data? = ? new ?ResultBuffer( new ?TypedValue(( int )DxfCode.Text,?prManagerNameRes.StringResult));?
????????????????????}
?
????????????????}


????????????????trans.Commit();?
????????????}
?
????????????
finally ?
????????????
{?
????????????????trans.Dispose();?
????????????}
?
????????}


????????[CommandMethod(
" LISTEMPLOYEES " )]?
????????
public ? void ?List()?
????????
{?
????????????Editor?ed?
= ?Application.DocumentManager.MdiActiveDocument.Editor;?
????????????
try ?
????????????
{?
????????????????PromptSelectionOptions?Opts?
= ? new ?PromptSelectionOptions();?
????????????????TypedValue[]?filList?
= ? new ?TypedValue[ 1 ];
?????????????????
// Build?a?filter?list?so?that?only?block?references?are?selected
????????????????filList[ 0 ]? = ? new ?TypedValue(( int )DxfCode.Start,? " INSERT " );?
????????????????SelectionFilter?filter?
= ? new ?SelectionFilter(filList);?
????????????????PromptSelectionResult?res?
= ?ed.GetSelection(Opts,?filter);?
????????????????
// Do?nothing?if?selection?is?unsuccessful
???????????????? if ?(res.Status? != ?PromptStatus.OK)?
????????????????????????
return ;?
????????????????Autodesk.AutoCAD.EditorInput.SelectionSet?SS?
= ?res.Value;?
????????????????ObjectId[]?idArray;
????????????????idArray?
= ?SS.GetObjectIds();?
????????????????
string []?saEmployeeList? = ? new ? string [ 4 ];?
????????????????
// collect?all?employee?details?in?saEmployeeList?array
???????????????? foreach ?(ObjectId?employeeId? in ?idArray)?
????????????????
{?
????????????????????ListEmployee(employeeId,?
ref ?saEmployeeList);?
????????????????????
// Print?employee?details?to?the?command?line
???????????????????? foreach ?( string ?employeeDetail? in ?saEmployeeList)?
????????????????????
{?
????????????????????????ed.WriteMessage(employeeDetail);?
????????????????????}
?
????????????????????
// separator
????????????????????ed.WriteMessage( " ---------------------- " ? + ? " \r\n " );?
????????????????}
?
????????????}
??
????????????
finally ?
????????????
{?
????????????}
?
????????}


????????[CommandMethod(
" Test " )]
????????
public ?? void ?Test()
????????
{
????????????CreateDivision(
" Sales " ,? " Randolph?P.?Brokwell " );
????????}

????}

}

posted on 2006-06-26 17:10 夢在天涯 閱讀(2143) 評論(1)  編輯 收藏 引用 所屬分類: ARX/DBX

評論

# re: 很好的arx學習代碼(.net版)[未登錄] 2009-06-24 01:51 kevin

iamwlb@qq.com
不知道為什么我的程序執行到database db的時候就異常了,不知道是不是不能脫離autocad運行?  回復  更多評論   

公告

EMail:itech001#126.com

導航

統計

  • 隨筆 - 461
  • 文章 - 4
  • 評論 - 746
  • 引用 - 0

常用鏈接

隨筆分類

隨筆檔案

收藏夾

Blogs

c#(csharp)

C++(cpp)

Enlish

Forums(bbs)

My self

Often go

Useful Webs

Xml/Uml/html

搜索

  •  

積分與排名

  • 積分 - 1812199
  • 排名 - 5

最新評論

閱讀排行榜

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
      <noscript id="pjuwb"></noscript>
            <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
              <dd id="pjuwb"></dd>
              <abbr id="pjuwb"></abbr>
              久久久久久一区| 午夜久久久久| 久久综合九色| 久久综合久色欧美综合狠狠 | 亚洲国产精品999| 久久这里只有| 日韩午夜在线视频| 一区二区三区四区五区视频| 国产精品久久久久毛片软件| 久久精品国产免费观看| 久久蜜桃香蕉精品一区二区三区| 亚洲欧洲一二三| 一区二区久久久久| 国产在线精品一区二区中文| 欧美国产极速在线| 国产精品爱啪在线线免费观看 | 国产日韩精品一区| 欧美激情一区二区三区高清视频| 欧美日韩一二三区| 久久久久国产精品麻豆ai换脸| 蜜臀99久久精品久久久久久软件 | 国产一区二区日韩| 亚洲国产精品精华液2区45| 国产精品精品视频| 欧美福利在线观看| 国产精品久久久久影院亚瑟 | 在线亚洲美日韩| 久久激情一区| 欧美中文日韩| 亚洲视频欧美视频| 麻豆91精品| 久久久精品性| 国产精品va在线播放| 欧美成人一品| 国产欧美高清| 亚洲视频二区| 亚洲毛片一区二区| 久久黄金**| 午夜精品久久久久久久久久久久| 欧美丰满高潮xxxx喷水动漫| 久久天堂av综合合色| 欧美日韩在线大尺度| 欧美大胆a视频| 国产自产v一区二区三区c| 一区二区三区视频在线看| 亚洲精品中文字幕有码专区| 亚洲九九爱视频| 欧美aⅴ一区二区三区视频| 国产精品亚洲欧美| 欧美一区综合| 一区二区三区**美女毛片| 欧美 日韩 国产 一区| 亚洲小说欧美另类婷婷| 在线电影欧美日韩一区二区私密| 欧美午夜精品久久久久免费视| 性做久久久久久| 亚洲美女黄色| 亚洲日本va在线观看| 久久精品亚洲一区二区三区浴池| 9久草视频在线视频精品| 伊人一区二区三区久久精品| 国产农村妇女毛片精品久久麻豆| 欧美日韩在线亚洲一区蜜芽| 欧美一区二区高清| 欧美视频官网| 欧美一区二区观看视频| 欧美四级在线观看| 亚洲欧洲精品一区二区三区波多野1战4 | 日韩视频专区| 亚洲无限av看| 国产精品久久影院| 亚洲一二三区精品| 欧美有码视频| 韩国v欧美v日本v亚洲v| 久久国产婷婷国产香蕉| 一区二区三区日韩欧美精品| 久久精品一本| 狠狠狠色丁香婷婷综合激情| 欧美一区二区三区在| 久久久综合激的五月天| 激情久久久久久| 嫩草国产精品入口| 亚洲精品日日夜夜| 亚洲综合色视频| 国产日韩一区欧美| 久久婷婷国产综合精品青草| 亚洲第一天堂av| 亚洲伊人久久综合| 国产亚洲欧美一区二区| 久久亚洲精品欧美| 亚洲精品一二区| 久久成人综合视频| 亚洲黄色影片| 欧美性猛交xxxx乱大交蜜桃| 欧美与欧洲交xxxx免费观看| 亚洲电影一级黄| 亚洲欧美影院| 亚洲娇小video精品| 国产精品theporn| 久久久亚洲人| 一本久道久久综合中文字幕| 久久久久.com| 亚洲少妇在线| 亚洲电影欧美电影有声小说| 欧美三级免费| 久久蜜臀精品av| 亚洲主播在线播放| 亚洲动漫精品| 久久久久久久波多野高潮日日| 亚洲三级免费电影| 国产亚洲精品自拍| 欧美日韩xxxxx| 久久精品国产亚洲一区二区| 亚洲九九精品| 亚洲福利在线看| 久久久噜噜噜久久中文字免| 亚洲少妇自拍| 日韩网站免费观看| 在线观看视频欧美| 国产精品视区| 国产精品大片免费观看| 免费人成精品欧美精品| 欧美一区视频在线| 亚洲特级毛片| 一本色道久久综合亚洲精品婷婷 | 9国产精品视频| 亚洲精品欧美日韩专区| 欧美1区2区3区| 久久久久久久综合色一本| 欧美亚洲网站| 亚洲欧美日韩中文播放| 亚洲手机成人高清视频| 亚洲精美视频| 最新日韩在线| 亚洲国产另类精品专区| 激情文学一区| 黄色一区二区三区| 好吊视频一区二区三区四区| 国产日韩欧美自拍| 国产精品自拍一区| 国产精品影院在线观看| 国产精品一区二区久久精品| 国产精品福利av| 国产精品视频久久一区| 国产精品色网| 国产一区 二区 三区一级| 国产午夜精品美女毛片视频| 亚洲天堂av在线免费观看| 亚洲美女中出| 亚洲国产日本| 亚洲日韩欧美视频一区| 夜夜嗨av一区二区三区中文字幕| 日韩一级在线| 亚洲一区影院| 久久久久久亚洲综合影院红桃| 久久久视频精品| 欧美成人午夜激情| 亚洲精品视频免费| 一区二区欧美视频| 欧美一区午夜精品| 免费观看一区| 国产精品福利网| 国语自产在线不卡| 91久久精品日日躁夜夜躁国产| aa国产精品| 久久成人精品视频| 欧美成人一区二区三区在线观看| 亚洲全部视频| 亚洲欧美中文另类| 久久综合精品国产一区二区三区| 欧美另类69精品久久久久9999| 国产精品久久久久久久7电影| 国产午夜亚洲精品羞羞网站| 亚洲国产精品va在看黑人| av成人激情| 久久免费少妇高潮久久精品99| 亚洲国产cao| 亚洲欧美日韩一区二区三区在线 | 一本久久综合亚洲鲁鲁| 久久国产手机看片| 欧美日韩午夜在线| 激情欧美国产欧美| 亚洲一区二区三区四区五区黄 | 久久黄色网页| 日韩五码在线| 久久亚洲图片| 国产欧美亚洲一区| 日韩网站在线| 欧美激情视频免费观看| 亚洲专区一二三| 欧美日韩精品二区第二页| 在线看成人片| 欧美在线观看天堂一区二区三区| 亚洲人成网在线播放| 欧美一区激情视频在线观看| 欧美日韩免费一区二区三区视频 | 国产精品99免费看| 亚洲精一区二区三区| 久久中文精品| 性色av一区二区三区在线观看|