Ширина текста на VBA ACAD 2008
| Правила | Регистрация | Пользователи | Сообщения за день |  Справка по форуму | Файлообменник |

Вернуться   Форум DWG.RU > Программное обеспечение > Программирование > Ширина текста на VBA ACAD 2008

Ширина текста на VBA ACAD 2008

Ответ
Поиск в этой теме
Непрочитано 12.03.2013, 09:41 #1
Ширина текста на VBA ACAD 2008
german-nk
 
ИНЖЕНЕР-СТРОИТЕЛЬ
 
Степногорск, Казахстан
Регистрация: 04.04.2010
Сообщений: 299

Дилетантский вопрос. Перерыл интернет и справочники.

Вот цитата из справочника: "You can use some other properties of a TextStyle object to set the way text appears: Height, Width, ObliqueAngle, and TextGenerationFlag". Все работает, но Width не работает.

Пример модуля из справки VBA, немного отредактировано.

Код:
[Выделить все]
Option Explicit
Sub Example_TextStyle()
   ' This example creates an aligned dimension in model space and
   ' creates a new system text style.  The new text style is then assigned to
   ' the new dimension

    Dim dimObj As AcadDimAligned
    Dim newText As AcadTextStyle
    Dim point1(0 To 2) As Double, point2(0 To 2) As Double
    Dim location(0 To 2) As Double
    
    ' Define the dimension
    point1(0) = 5: point1(1) = 5: point1(2) = 0
    point2(0) = 5.5: point2(1) = 5: point2(2) = 0
    location(0) = 5: location(1) = 7: location(2) = 0
    
    ' Create an aligned dimension object in model space
    Set dimObj = ThisDrawing.ModelSpace.AddDimAligned(point1, point2, location)
    
    ' Create new text style
    Set newText = ThisDrawing.TextStyles.Add("MYSTYLE")
    newText.Height = 10    ' Just set the height of the new style so we can differentiate. Это работает
    
    Dim Widht As Double
    newText.Widht = 0.8     'Вот это не работает
    
    Dim ObliqueAngle As Double
    newText.ObliqueAngle = 0.1 'Это работает
    ThisDrawing.Application.ZoomAll
    
    ' Read and display the current text style for this dimension
    MsgBox "The text style is currently set to: " & dimObj.TextStyle
    
    ' Change the text style to use the new style we created
    dimObj.TextStyle = "MYSTYLE"
    ThisDrawing.Regen acAllViewports
    
    ' Read and display the current text style for this dimension
    MsgBox "The text style is now set to: " & dimObj.TextStyle

End Sub
Сам не могу сообразить и ответ найти не могу. Нужно отредактировать готовый модуль, а программист уволился и уехал в Россию.
__________________
Строил, - знаю
Просмотров: 3604
 
Непрочитано 12.03.2013, 09:56
1 | #2
trir


 
Регистрация: 18.12.2010
Сообщений: 5,108


newText.Width
trir вне форума  
 
Непрочитано 12.03.2013, 15:28
1 | #3
Олег (jr.)

специалист по околачиванию грушевых деревьев
 
Регистрация: 14.09.2004
Pietari, Venäjä
Сообщений: 811


Попробуй сначала изменить шрифт, затем ширину,
в 2009 работает


Код:
[Выделить все]
Option Explicit

Sub Example_TextStyle()
   ' This example creates an aligned dimension in model space and
   ' creates a new system text style.  The new text style is then assigned to
   ' the new dimension

    Dim dimObj As AcadDimAligned
    Dim newTextStyle As AcadTextStyle
    Dim point1(0 To 2) As Double, point2(0 To 2) As Double
    Dim location(0 To 2) As Double
    
      Dim typeFace As String
    Dim Bold As Boolean
    Dim Italic As Boolean
    Dim charSet As Long
    Dim PitchandFamily As Long
    
    ThisDrawing.ActiveTextStyle.GetFont typeFace, Bold, Italic, charSet, PitchandFamily
 
    On Error Resume Next
    Set newTextStyle = ThisDrawing.TextStyles.Item("MYSTYLE")
    If Err Then
    Err.Clear
    On Error GoTo 0
    End If
    
   ' Create new text style
   Set newTextStyle = ThisDrawing.TextStyles.Add("MYSTYLE")
   ' Set font name
   typeFace = "arial"
   
   newTextStyle.SetFont typeFace, Bold, Italic, charSet, PitchandFamily
   
    newTextStyle.Height = 10    ' Just set the height of the new style so we can differentiate. Это работает
    
    Dim Widht As Double
    newTextStyle.Width = 0.8     'Вот это A2009 работает
    
    Dim ObliqueAngle As Double
    newTextStyle.ObliqueAngle = 0.1 'Это работает
    
    ThisDrawing.Application.ZoomAll
    
  
    
    ' Define the dimension
    point1(0) = 5: point1(1) = 5: point1(2) = 0
    point2(0) = 5.5: point2(1) = 5: point2(2) = 0
    location(0) = 5: location(1) = 7: location(2) = 0
    
    ' Create an aligned dimension object in model space
    Set dimObj = ThisDrawing.ModelSpace.AddDimAligned(point1, point2, location)
    
  ' Change the text style to use the new style we created
    dimObj.TextStyle = "MYSTYLE"
    ThisDrawing.Regen acAllViewports
    
    ' Read and display the current text style for this dimension
    MsgBox "The text style is now set to: " & dimObj.TextStyle

End Sub
Олег (jr.) вне форума  
 
Непрочитано 12.03.2013, 15:32
1 | #4
Кулик Алексей aka kpblc
Moderator

LISP, C# (ACAD 200[9,12,13,14])
 
Регистрация: 25.08.2003
С.-Петербург
Сообщений: 40,431


german-nk, для справки: ширина текста - это одно, а коэффициент сжатия для текстового стиля - совсем другое.
__________________
Моя библиотека lisp-функций
---
Обращение ко мне - на "ты".
Все, что сказано - личное мнение.
Кулик Алексей aka kpblc вне форума  
Ответ
Вернуться   Форум DWG.RU > Программное обеспечение > Программирование > Ширина текста на VBA ACAD 2008

Реклама i


Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Autocad Archtectural 2008 долго грузит файл по причине форматирования текста при загрузке tigercron Вертикальные решения на базе AutoCAD 10 12.04.2018 19:20
Проблема со шрифтами Acad 2006 - Acad 2008 Cartman AutoCAD 40 15.03.2013 09:05
при выборе команды редактирование текста вырубается Acad Nikolays AutoCAD 4 24.10.2007 09:14
ACAD 2006. Пустой прямоугольник вместо текста KinSokol AutoCAD 2 19.05.2006 14:06
ACAD LT + lisp / vba Кулик Алексей aka kpblc LISP 16 30.03.2006 22:04