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

Text in block reference:

6 REPLIES 6
Reply
Message 1 of 7
quigs
458 Views, 6 Replies

Text in block reference:

Good afternoon:

The following code inserts a circle at a point intoa block reference:
myBTR.AppendEntity(New Circle( New Point3d(0, 0, 0), New Vector3d(0, 0, 1), 1.5))
Can anyone help me with a way to insert a piece of text, I have been searching in vain for days & can't work it out,

thanks,

Martin..
My name is Martin.. 😄
6 REPLIES 6
Message 2 of 7
Hallex
in reply to: quigs

Try this simple example
Btw, did you tryed to search for an answer on this forum?

{code}
Imports System
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Geometry

< commandclass="">

Namespace BlockTools
Public Class BlockCommands
Public Shared Sub AddBlock(ByVal bname As String)
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim db As Database = doc.Database
Using doclock As DocumentLock = doc.LockDocument()
Using tr As Transaction = db.TransactionManager.StartTransaction()
Dim bt As BlockTable = CType(tr.GetObject(db.BlockTableId, OpenMode.ForWrite, False), BlockTable)
Dim btr As New BlockTableRecord
btr.Name = bname
btr.Origin = New Point3d(0, 0, 0)
bt.Add(btr)
tr.AddNewlyCreatedDBObject(btr, True)
Dim circle As New Circle(New Point3d(0, 0, 0), New Vector3d(0, 0, 1), 1.0)
btr.AppendEntity(circle)
tr.AddNewlyCreatedDBObject(circle, True)
Dim text As New DBText
text.Position = New Point3d(0, 1.1, 0)
text.TextString = "text above circle"
text.HorizontalMode = TextHorizontalMode.TextMid
text.VerticalMode = TextVerticalMode.TextBottom
text.AlignmentPoint = New Point3d(0, 1.1, 0)
text.AdjustAlignment(db)
btr.AppendEntity(text)
tr.AddNewlyCreatedDBObject(text, True)
tr.Commit()
End Using
End Using

End Sub

_
Public Shared Sub CreateBlock()
AddBlock("MyCoolBlock")
End Sub
End Class
End Namespace
{code}

~'J'~
_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 3 of 7
quigs
in reply to: quigs

Hi Hallex,
yeah i did, I searched many different
search combination's, but couldn't find
anything.

Thank you for your help though.

Cheers,

Martin.
My name is Martin.. 😄
Message 4 of 7
Hallex
in reply to: quigs

You're welcome
Happy computing

~'J'~
_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 5 of 7
Anonymous
in reply to: quigs

Just wondering why your code was unformatted in my newsreader.

Can you tell me how you posted this?


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2010

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6298242@discussion.autodesk.com...
Try this simple example Btw, did you tryed to search for an answer on this
forum? {code} Imports System Imports Autodesk.AutoCAD.Runtime Imports
Autodesk.AutoCAD.ApplicationServices Imports
Autodesk.AutoCAD.DatabaseServices Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Geometry Namespace BlockTools Public Class
BlockCommands Public Shared Sub AddBlock(ByVal bname As String) Dim doc As
Document = Application.DocumentManager.MdiActiveDocument Dim db As Database
= doc.Database Using doclock As DocumentLock = doc.LockDocument() Using tr
As Transaction = db.TransactionManager.StartTransaction() Dim bt As
BlockTable = CType(tr.GetObject(db.BlockTableId, OpenMode.ForWrite, False),
BlockTable) Dim btr As New BlockTableRecord btr.Name = bname btr.Origin =
New Point3d(0, 0, 0) bt.Add(btr) tr.AddNewlyCreatedDBObject(btr, True) Dim
circle As New Circle(New Point3d(0, 0, 0), New Vector3d(0, 0, 1), 1.0)
btr.AppendEntity(circle) tr.AddNewlyCreatedDBObject(circle, True) Dim text
As New DBText text.Position = New Point3d(0, 1.1, 0) text.TextString = "text
above circle" text.HorizontalMode = TextHorizontalMode.TextMid
text.VerticalMode = TextVerticalMode.TextBottom text.AlignmentPoint = New
Point3d(0, 1.1, 0) text.AdjustAlignment(db) btr.AppendEntity(text)
tr.AddNewlyCreatedDBObject(text, True) tr.Commit() End Using End Using End
Sub _ Public Shared Sub CreateBlock() AddBlock("MyCoolBlock") End Sub End
Class End Namespace {code} ~'J'~
Message 6 of 7
Hallex
in reply to: quigs

I used "Plain Text" tab and included code
between the curled brackets like this:
{ code } code goes here { code }
Thanks,

~'J'~
_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 7 of 7
Anonymous
in reply to: quigs

That's odd.

It's completely reformatted in my newsreader.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2010

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6299350@discussion.autodesk.com...
I used "Plain Text" tab and included code
between the curled brackets like this:
{ code } code goes here { code }
Thanks,

~'J'~

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost