Quantcast
Channel: Autodesk AutoCAD forums
Viewing all articles
Browse latest Browse all 14319

Leader with annotation take long time to create

$
0
0

Hi All,

 

To create a leader with annotation , I am using below code. Leader and annotation create without any problem. But one disgusting thing is that it took very long time if I use the command first time after opening ACAD. But afterwards when I use the command it execute very quickly. Can any body help me to optimize this code?

 

<CommandMethod("leadertest")> PublicSubleadertest()

 

Application.SetSystemVariable("dimldrblk", "_dot")

 

Dim acDoc AsDocument = Application.DocumentManager.MdiActiveDocument

 

Dim acCurDb AsDatabase= acDoc.Database

 

Using acTrans AsTransaction= acCurDb.TransactionManager.StartTransaction()

 

Dim acBlkTbl AsBlockTable

acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,

OpenMode.ForRead)

 

Dim acBlkTblRec AsBlockTableRecord

acBlkTblRec = acTrans.GetObject(acBlkTbl(

BlockTableRecord.ModelSpace), OpenMode.ForWrite)

 

Dim mtextId AsObjectIdDim mtxt AsMText = NewMText()

mtxt.SetDatabaseDefaults()

mtxt.Contents =

"first line/sencond line"

mtxt.Location =

NewPoint3d(4, 4, 0)

mtxt.TextHeight = 0.25

mtxt.Attachment =

AttachmentPoint.MiddleLeft

mtxt.SetAttachmentMovingLocation(mtxt.Attachment)

mtextId = acBlkTblRec.AppendEntity(mtxt)

acTrans.AddNewlyCreatedDBObject(mtxt,

True)

 

Dim acLdr AsLeader = NewLeader()

acLdr.SetDatabaseDefaults()

acLdr.AppendVertex(

NewPoint3d(2, 2, 0))

acLdr.AppendVertex(

NewPoint3d(4, 4, 0))

acLdr.Dimasz = 0.25

acBlkTblRec.AppendEntity(acLdr)

acTrans.AddNewlyCreatedDBObject(acLdr,

True)

acLdr.Annotation = mtextId

acLdr.Dimsah =

False

acLdr.Dimtad = 0

acLdr.Dimgap = 0.25

acLdr.EvaluateLeader()

acTrans.Commit()

EndUsingApplication.ShowAlertDialog("finish")EndSub

 

Thanks in advance.

Regards

Zakir

 


Viewing all articles
Browse latest Browse all 14319

Trending Articles