Community
Hi All,
I have a problem, hope everybody can help me. This is, where can i put this code: ppo.UseBasePoint = True ,ppo.BasePoint = pt1,ppo.UseDashedLine = True into my program:
<CommandMethod("dd")> Public Sub DrawText() Dim doc As Document = Application.DocumentManager.MdiActiveDocument Dim ed As Editor = doc.Editor Dim db As Database = doc.Database doc.LockDocument() Dim ppo As PromptPointOptions = New PromptPointOptions("") ppo.Message = vbLf & "Choose the first vertex of the square: " Dim ppr As PromptPointResult = ed.GetPoint(ppo) If ppr.Status <> PromptStatus.OK Then Return End If Dim pt1 As Point3d = ppr.Value '' Start a transaction Using acTrants As Transaction = db.TransactionManager.StartTransaction() Dim acBlkTbl As BlockTable acBlkTbl = acTrants.GetObject(db.BlockTableId, _ OpenMode.ForRead) '' Open the Block table record Model space for write Dim acBlkTblRec As BlockTableRecord acBlkTblRec = acTrants.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), _ OpenMode.ForWrite) ''Create a single-line text object Dim acText As DBText = New DBText() acText.SetDatabaseDefaults() acText.Position = ppr.Value acText.Height = 100 acText.TextString = "Cadviet" acText.WidthFactor = 0.8 acText.HorizontalMode = TextHorizontalMode.TextCenter acText.VerticalMode = TextVerticalMode.TextVerticalMid acText.AlignmentPoint = ppr.Value acBlkTblRec.AppendEntity(acText) acTrants.AddNewlyCreatedDBObject(acText, True) acTrants.Commit() End Using ppo.Message = vbLf & "Choose the second vertex of the square: " ppo.UseBasePoint = True ppo.BasePoint = pt1 ppo.UseDashedLine = True ppr = ed.GetPoint(ppo) End Sub
I use "MULTIPLE" in comman line of autocad, so i want to create one more acText. Thanks Everybody.
Hi,
Sorry, didnt understand you question correctly.
What is the purpose of picking those two points ?
You want to place text at those two points ?
You can just clone text something like this:
<CommandMethod("dctext")> _ Public Sub DrawCopyText() Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument Dim ed As Editor = doc.Editor Dim db As Database = doc.Database doc.LockDocument() Dim ppo As PromptPointOptions = New PromptPointOptions("") ppo.Message = vbLf & "Choose the first vertex of the square: " Dim ppr As PromptPointResult = ed.GetPoint(ppo) If ppr.Status <> PromptStatus.OK Then Return End If Dim pt1 As Point3d = ppr.Value '' Start a transaction Using acTrants As Transaction = db.TransactionManager.StartTransaction() Dim acBlkTbl As BlockTable acBlkTbl = acTrants.GetObject(db.BlockTableId, _ OpenMode.ForRead) '' Open the Block table record Model space for write Dim acBlkTblRec As BlockTableRecord acBlkTblRec = acTrants.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), _ OpenMode.ForWrite) ''Create a single-line text object Dim acText As DBText = New DBText() acText.SetDatabaseDefaults() acText.Position = pt1 acText.Height = 100 acText.TextString = "Cadviet" acText.WidthFactor = 0.8 acText.HorizontalMode = TextHorizontalMode.TextCenter acText.VerticalMode = TextVerticalMode.TextVerticalMid acText.AlignmentPoint = pt1 acBlkTblRec.AppendEntity(acText) acTrants.AddNewlyCreatedDBObject(acText, True) ppo.Message = vbLf & "Choose the second vertex of the square: " ppo.UseBasePoint = True ppo.BasePoint = pt1 ppo.UseDashedLine = True ppr = ed.GetPoint(ppo) Dim pt2 As Point3d = ppr.Value Dim vec As Vector3d = pt2 - pt1 Dim acText2 As DBText = CType(acText.Clone, DBText) acText2.TransformBy(Matrix3d.Displacement(vec)) acBlkTblRec.AppendEntity(acText2) acTrants.AddNewlyCreatedDBObject(acText2, True) acTrants.Commit() End Using End Sub