ksTable

Автор HaHa, 26.01.13, 20:21:30

« назад - далее »

0 Пользователи и 1 гость просматривают эту тему.

HaHa

Исходя из документации, ksTable это составной объект(ksLineSeg и ksText), таким образом запаришься таблицу строит, не подскажете нет ли другого способа создания таблицы и работы с ней?


HaHa

спасибо :)

HaHa

Создаю таблицу


var
TableDraw: IDrawingTables;
....
TableDraw.Add(8, 4, 30, 50);
...

Выдает ошибку


HaHa

точки это пропущенный код :)

26.01.13, 21:23:00 #6 Последнее редактирование: 26.01.13, 21:45:09 от Sabahs
...

HaHa


HaHa


var
  DocTable: IDrawingTable;
  DocTables: IDrawingTables;
  SymbolContainer: ISymbols2DContainer;
begin
.....
DocTables:= SymbolContainer.DrawingTables;
DocTable:= DocTables.Add(10, 10, 10, 10, 2);

все равно ошибка:-(

Какая ошибка, нет никакой ошибки, если Вы считаете, что DocTable:= DocTables.Add(10, 10, 10, 10, 2); достаточно, то Вы заблуждаетесь.

HaHa

Вы имеете ввиду про координаты точки привязки?Или еще что есть?

Я говорю о том, что её создать нужно, Вы получили только интерфейс таблицы.
Смотрите

HaHa

незнаю даже что и думать, делаю как у Вас, все равно ошибка


DocTables:= SymbolContainer.DrawingTables;
DocTable:= DocTables.Add(10, 10, 10, 10, 2);
DocTable.X:= 100;
DocTable.Y:= 100;
DocTable.Angle:= 0;
DocTable.Update;

Картинку ошибки можно посмотреть.

HaHa

Постарался в точности как у вас, хотя может где нить и накосячил

var
  KompasDocument2D:       IKompasDocument2D;
  ViewsAndLayersManager:  IViewsAndLayersManager;
  Views:                  IViews;
  View:                   IView;
  DocTable:               IDrawingTable;
  DocTables:              IDrawingTables;
  SymbolContainer:        ISymbols2DContainer;
begin
  ViewsAndLayersManager:= KompasDocument2D.ViewsAndLayersManager;
  if ViewsAndLayersManager <> nil then
  begin
    Views:= ViewsAndLayersManager.Views;
    if Views <> nil then
    begin
      View:= Views.ActiveView;
      if View <> nil then
      begin
        SymbolContainer:= View as ISymbols2DContainer;
        if SymbolContainer <> nil then
        begin
          DocTables:= SymbolContainer.DrawingTables;
          if DocTables <> nil then
          begin
            DocTable:= DocTables.Add(10, 10, 10, 10, 2);
            if DocTable <> nil then
            begin
              DocTable.X:= 100;
              DocTable.Y:= 100;
              DocTable.Angle:= 0;
              DocTable.Update;
              DocTable:= nil;
            end;
            DocTables:= nil;
          end;
          SymbolContainer:= nil;
        end;
        View:= nil;
      end;
      Views:= nil;
    end;
    ViewsAndLayersManager:= nil;
  end;
end;

PS

А как Вы получили IKompasDocument2D?

27.01.13, 20:32:39 #16 Последнее редактирование: 27.01.13, 20:52:47 от Sabahs
У Вас KompasDocument2D равен nil Вы до таблицы и не доходите, а точнее вылетаете на самой первой строке.

KompasAPI:IApplication;

KompasDocument:=KompasAPI.ActiveDocument;
  if KompasDocument<>nil then
   begin
     if(KompasDocument.Type_=ksDocumentDrawing)or(KompasDocument.Type_=ksDocumentFragment)then
      Doc7:=KompasDocument as IKompasDocument2D;
   end;

HaHa


KompasDocument2D:= Application.ActiveDocument as IKompasDocument2D;

Можно и так, но нужно проверку делать, иначе опять полетите, если окажется, что активен 3D документ.
if(KompasDocument.Type_=ksDocumentDrawing)or(KompasDocument.Type_=ksDocumentFragment)then

HaHa

уже запарился

var
  Application:            IApplication;
  KompasDocument2D:       IKompasDocument2D;
  ViewsAndLayersManager:  IViewsAndLayersManager;
  Views:                  IViews;
  View:                   IView;
  DocTable:               IDrawingTable;
  DocTables:              IDrawingTables;
  SymbolContainer:        ISymbols2DContainer;
begin
  KompasDocument2D:= Application.ActiveDocument as IKompasDocument2D;
  if KompasDocument2D <> nil then
  begin
    ViewsAndLayersManager:= KompasDocument2D.ViewsAndLayersManager;
    if ViewsAndLayersManager <> nil then
    begin
      Views:= ViewsAndLayersManager.Views;
      if Views <> nil then
      begin
        View:= Views.ActiveView;
        if View <> nil then
        begin
          SymbolContainer:= View as ISymbols2DContainer;
          if SymbolContainer <> nil then
          begin
            DocTables:= SymbolContainer.DrawingTables;
            if DocTables <> nil then
            begin
              DocTable:= DocTables.Add(10, 10, 10, 10, 2);
              if DocTable <> nil then
              begin
                DocTable.X:= 100;
                DocTable.Y:= 100;
                DocTable.Angle:= 0;
                DocTable.Update;
                DocTable:= nil;
              end;
              DocTables:= nil;
            end;
            SymbolContainer:= nil;
          end;
          View:= nil;
        end;
        Views:= nil;
      end;
      ViewsAndLayersManager:= nil;
    end;
    Application:= nil;
  end;
end;

активен чертеж