Solved

How to grab insertion point of mtext?

Posted on 2006-11-28
6
597 Views
Last Modified: 2010-05-18
I'm trying to take the following URL http://www.experts-exchange.com/Applications/CAD/Q_21389353.html?query=need+insertion+point+for+mtext&clearTAFilter=true and decipher it to allow me to take the following code (listed below) and find the insertion point of mtext so that I can print out the values to a text file alonside of the mtext's values.  Could you please guide me in the correct direction to change the following code to also print out the insertion point of the mtext found?  Thank you for all the help in the past.

Public Sub ExtractText()

  Dim acadapp As AutoCAD.AcadApplication
  Dim acadDoc As AutoCAD.AcadDocument
  Dim objSelSet As AcadSelectionSet
  Dim objSelCol As AcadSelectionSets
  Dim objBlkCol As AcadBlocks
  Dim objBlk As AcadBlock
  Dim intType(0) As Integer
  Dim varData(0) As Variant
  Dim objBlkRef As AutoCAD.AcadBlockReference
  Dim objAttRef As AutoCAD.AcadAttributeReference
  Dim vAtts As Variant
  Dim aCode(1)      As Integer
  Dim aValue(1)     As Variant
  Dim vCode         As Variant
  Dim vValue        As Variant
  Dim iLoop         As Integer
  Dim iLoop2        As Integer
  Dim I As Long
  Dim J As Long
  Dim intI As Integer
  Dim sSelect As String
  Dim rstDataDwg As DAO.Recordset
  Dim rstData As DAO.Recordset
  Dim lDwgID As Long
  Dim strPath As String
  Dim lBlock As Long
  Dim lAtt As Long
  Dim bAttChk As Boolean
  Dim obj As AcadObject
 
  Dim objEntity As AcadEntity
  Dim strKeyWords As String
  Dim varAttributeRef As Variant
  Dim objBlockDef As AcadBlock
  Dim strFileName As String
  Dim intFileID As Integer
 
  ' Initialize the keywords string.
  strKeyWords = ""
  txtStatus = "opening dwg..."
  DoEvents
  Set acadDoc = GetObject(txtPath)
  Set acadapp = acadDoc.Application
  Set objSelCol = acadDoc.SelectionSets
  Set objBlkCol = acadDoc.Blocks
 
   ' Get all of the text entities and block attributes in model space.
  For Each objEntity In acadDoc.ModelSpace
    I = I + 1
    txtStatus = "Found: " & objEntity.ObjectName & " at: " & I & " out of ?"
    DoEvents
    If TypeOf objEntity Is AcadMText Then
      txtStatus = "Found: " & objEntity.ObjectName & " at: " & I & " out of ?" & " --- found text: " & objEntity.TextString
      strKeyWords = strKeyWords & objEntity.TextString & vbCrLf
     'strKeyWords = strKeyWords & objEntity.Start & vbTab & objEntity.End <--- doesn't work
     'need additional start and end point of object...

     End If
  Next objEntity
 
  Set objBlkCol = Nothing
  Set objSelCol = Nothing
  Set acadapp = Nothing
   
  ' Write the keywords out to a file.
  strFileName = Left(acadDoc.FullName, Len(acadDoc.FullName) - 4)
  strFileName = strFileName & "_keywords.txt"
 
  Set acadDoc = Nothing
 
  intFileID = FreeFile
  Open strFileName For Output As intFileID
  Print #intFileID, strKeyWords
  Close #intFileID

End Sub
0
Comment
Question by:stephenlecomptejr
  • 3
  • 2
6 Comments
 
LVL 15

Expert Comment

by:OMC2000
ID: 18028999
Have you tried

strKeyWords = strKeyWords & objEntity.Insertionpoint(0) & vbTab & objEntity.Insertionpoint(1)

instead of

strKeyWords = strKeyWords & objEntity.Start & vbTab & objEntity.End <--- doesn't work
?
0
 
LVL 1

Author Comment

by:stephenlecomptejr
ID: 18029452
I tried that and I get a Run-time error '451'

Property let procedure not defined and property get procedure did not return an object
with the highlight on that exact line statement.
0
 
LVL 10

Accepted Solution

by:
norrin_radd earned 500 total points
ID: 18036984
I think I understand the question but the objentity.start and .end kinda confused me. but I think if you are trying to get the insertion points you have to get it in an array of the 3 points. this is a litttle piece of your code that I looked at and tinkered with:
'**************
Sub Mtext_insertion_test()
 Dim objEntity As AcadEntity
 Dim mltext As AcadMText
 Dim mltxt_inspnt(0 To 2) As Variant
For Each objEntity In ThisDrawing.ModelSpace
'    i = i + 1
'    txtStatus = "Found: " & objEntity.ObjectName & " at: " & i & " out of ?"
'    DoEvents
    If TypeOf objEntity Is AcadMText Then
   Set mltext = objEntity
   mltxt_inspnt(0) = mltext.insertionPoint(0)
    'MsgBox mltext.ObjectName
      txtStatus = "Found: " & objEntity.ObjectName & " at: " & i & " out of ?" & " --- found text: " & objEntity.textString
      strkeywords = strkeywords & mltxt_inspnt(0) & vbCrLf
     'strKeyWords = strKeyWords & mltxt_inspnt(0) & vbTab < ---doesn 't work
     'need additional start and end point of object...
 'MsgBox strkeywords
     End If
  Next objEntity
'****************

you may not have to dim a seperate variant for the array, it works this way or if you just go straight for the mltext.insertionpoint(0) in the strkeywords line.
this just gets the x coord, maybe that'll help.
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 1

Author Comment

by:stephenlecomptejr
ID: 18039645
yea - norrin radd again to the rescue.

I'm sure glad you have not "retired" fulltime.

I just need some more instruction on how the insertion points work.

When I print out the insertion point of a specific mtext that contains the text: #52.1 for instance and I do a mltext.insertionpoint(0) and it gives me 1316624.97411137 - what exactly does that value mean?

All I know is that where the text was originally inserted into the drawing.
Is this number 1316624.97411137 the number for the X coordinate only since I requested mltext.insertionpoint(0)?
Is the y coordinate available as mltext.insertionpoint(1)?

or the full insertion point is just that 1316624.97411137 only with the 1316624 as the X and the 97411137 as the Y?


0
 
LVL 10

Expert Comment

by:norrin_radd
ID: 18039841
"Is this number 1316624.97411137 the number for the X coordinate only since I requested mltext.insertionpoint(0)?
Is the y coordinate available as mltext.insertionpoint(1)?"

yup you got it, y is mltext.insertionpoint(1), z is mltext.insertionpoint(2)
when ever you are after points of any kind 99.999% of the time you are going to have to get it in an array of x,y,z,

"I'm sure glad you have not "retired" fulltime."
 
nah, slowed down a little but not retired, funny, I almost made a career change recently though, thats kinda scary.
0
 
LVL 10

Expert Comment

by:norrin_radd
ID: 18039997
Ps omc was close, but I had to do that acadentity to acadmtext (Set mltext = objEntity) switch-a-roo to get to the insertionpoints, i was going to mention that earlier.....
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

If, like me, you find yourself repeatedly and tediously joining many segments (lines, arcs) in other people's drawings back into polylines that can be used more effectively in Computer Aided Machining and Laser Cutting, then this article is for you!…
The following article will describe how to add/edit a dimension style through AutoCAD VBA. AutoCAD VBA has its quirks and when it comes to dimensions and controlling how they look through VBA.  This is where AutoCAD can be vividly confusing. The…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now