.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Reply
Message 1 of 8
Anonymous
260 Views, 7 Replies

Hi Fatty

ent is not AcadDimDiametric its AcadMText

So How can i add prefix for an Mtext %%30 similarly for all the mtext which is written as %%C--
7 REPLIES 7
Message 2 of 8
jbooth
in reply to: Anonymous

Please use the "Reply" button instead of the "Post New Topic" button.
Message 3 of 8
Anonymous
in reply to: Anonymous

Ok,
ent is not AcadDimDiametric its AcadMText

So How can i add prefix for an Mtext %%30 similarly for all the mtext which is written as %%C--
Message 4 of 8
Anonymous
in reply to: Anonymous

First of I agreed with Jason
Second, you got me man, indeed
Please do not ask me personaly,
I will not help you again, this is very
basics, see Help

~'J'~


Sub AddPrefToMText()

Dim oSset As AcadSelectionSet
Dim oEnt As AcadObject
Dim fcode(1) As Integer
Dim fData(1) As Variant
Dim dxfcode, dxfdata
Dim i As Integer
Dim setName As String

setName = "$MTEXTS$"

For i = 0 To ThisDrawing.SelectionSets.Count - 1
If ThisDrawing.SelectionSets.Item(i).Name = setName Then
ThisDrawing.SelectionSets.Item(i).Delete
Exit For
End If
Next i

Set oSset = ThisDrawing.SelectionSets.Add(setName)


Dim pref As String, newpref As String
pref = InputBox(vbNewLine & "Enter prefix to search" & vbNewLine & _
"press Enter to set default", _
"MText Prefix", "%%C")

newpref = InputBox(vbNewLine & "Enter prefix to replace" & vbNewLine & _
"press Enter to set default", _
"MText Prefix", "%%30")

fcode(0) = 0: fData(0) = "MTEXT"
fcode(1) = 1: fData(1) = pref & "*" '// <-- build mask

dxfcode = fcode
dxfdata = fData

oSset.Select acSelectionSetAll, , , dxfcode, dxfdata
' MsgBox oSset.Count 'debug only
If oSset.Count > 0 Then

Dim oMText As AcadMText

For Each oMText In oSset
Dim txtStr As String
txtStr = oMText.TextString
oMText.TextString = newpref & Right$(oMText.TextString, Len(oMText.TextString) - Len(pref))
Next
End If

End Sub
Message 5 of 8
Anonymous
in reply to: Anonymous

Hi,
Here i have one more doubt.after assigning parameters to all the dimensions i want to extract all the dimensions and parameters to an excel sheet.

The tolerance value will be written as mtext in the drawing
(example +10 -20) with the dimension value.The excel sheet
must contain the tolerance value(+ and -) also in seperate columns .
I have attached the Excel sheet format and also the sample drawing which i want to customize
Message 6 of 8
Anonymous
in reply to: Anonymous

here is the drawing which i want to customize
Message 7 of 8
Anonymous
in reply to: Anonymous

Hi Fatty,
Iam trying with the code but come across with some problem this the code which i tried for extracting to excel.Please help me

Dim dimtext As String
Dim database As AcadDatabase

Public obook As Excel.Workbook
Public introw As Integer
Public strcell As String
Public oexcel As Excel.Application
Public osheet As Excel.Worksheet

Dim obj As AcadEntity
Dim txt As AcadMText
'Dim objtext As AcadDimension

Dim varinsert As Object
Dim ssett As AcadSelectionSet

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
oexcel = CreateObject("Excel.Application")
obook = oexcel.Workbooks.Add
osheet = obook.Worksheets(1)
oexcel.Visible = True
oexcel.Cells(1, 1).Value = "PARAMETER"
oexcel.Cells(1, 2).Value = "MEASUREMENT"
oexcel.Cells(1, 3).Value = "TEXT"
oexcel.Cells(1, 4).Value = "MTEXT"



introw = 5
For Each ent In acadDoc.ModelSpace
If TypeOf ent Is AcadDimension Then

txt = obj
'oexcel.Cells(introw, 1).Value = acadDoc.Name
oexcel.Cells(introw, 1).Value = ent.TextPrefix
oexcel.Cells(introw, 2).Value = ent.Measurement
introw = introw + 1


ElseIf TypeOf ent Is AcadText Then

oexcel.Cells(introw, 3).Value = ent.TextString

ElseIf TypeOf ent Is AcadMText Then
oexcel.Cells(introw, 4).Value = ent.TextString


'varinsert = objtext.InsertionPoint

'oexcel.Cells(introw, 1).Value = varinsert(0)
'oexcel.Cells(introw, 2).Value = varinsert(1)
introw = introw + 1
End If
Next ent
End Sub
Message 8 of 8
Anonymous
in reply to: Anonymous

Hi
I can test it just an quick changes
I have not have a time on that now

~'J'~

Dim dimtext As String
Dim database As AcadDatabase

Public obook As Excel.Workbook
Public introw As Integer
Public strcell As String
Public oexcel As Excel.Application
Public osheet As Excel.Worksheet
Dim ent As AcadEntity
Dim obj As AcadEntity
Dim oMtext As AcadMText
Dim oText As AcadText
Dim objtext As AcadDimension
Dim varinsert As Object
Dim ssett As AcadSelectionSet

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
oexcel = CreateObject("Excel.Application")
obook = oexcel.Workbooks.Add
osheet = obook.Worksheets(1)
oexcel.Visible = True
oexcel.Cells(1, 1).Value = "PARAMETER"
oexcel.Cells(1, 2).Value = "MEASUREMENT"
oexcel.Cells(1, 3).Value = "TEXT"
oexcel.Cells(1, 4).Value = "MTEXT"



introw = 5
For Each ent In acadDoc.ModelSpace
If TypeOf ent Is AcadDimension Then
objtext = ent
'oexcel.Cells(introw, 1).Value = acadDoc.Name
oexcel.Cells(introw, 1).Value = objtext.TextPrefix
oexcel.Cells(introw, 2).Value = objtext.Measurement
introw = introw + 1


ElseIf TypeOf ent Is AcadText Then
oText = ent
oexcel.Cells(introw, 3).Value = oText.TextString

ElseIf TypeOf ent Is AcadMText Then
oMtext = ent
oexcel.Cells(introw, 4).Value = oMtext.TextString


'varinsert = objtext.InsertionPoint

'oexcel.Cells(introw, 1).Value = varinsert(0)
'oexcel.Cells(introw, 2).Value = varinsert(1)
introw = introw + 1
End If
Next ent

End Sub Message was edited by: Fatty

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