Bleche im Stahlprofileditor verschieben und kopieren

19. August 2008 15:49

Im Faltwerk gehts, im Stahlprofileditor fehlt er leider, der Befehl "Geometrie verschieben". Das ist lästig, wenn man zusammengesetzte Querschnitte aus importierten Querschnitten anlegen will, denn mit einem einfachen "Kopier" Befehl geht diese Arbeit viel leichter von der Hand.

Als Lösung bis der "richtige" Befehl verfügbar wird, hier ein kleines Makro, das die zur Zeit ausgewählten Bleche um ein Delta in Y und Z verschiebt, und dabei Kopien anlegt. Knoten werden bei Bedarf ebenfalls kopiert. (Bitte Achtung: Kein offizielles Programmstück, nicht supportet oder gewartet und schon gar nicht ausführlich getestet... Sollte aber gehen :-) )

--

using System;
using DIE.Framework.ApplicationModell.Scripting;
using DIE.Framework.ApplicationModell.Commands;
using DIE.Framework.DocumentModell;
using DIE.Framework.ObjectModell;
using DIE.Geometry;

using DIE.Applications.ProfileEditor.Objects.Nodes;
using DIE.Applications.ProfileEditor.Objects.Beams;

namespace MeineMakros
{
 public class SPE : UserCommandBase
 {
    private class Dyz
    {
   private double y,z;
       public double Y { get { return y;} set { y = value; }}
       public double Z { get { return z;} set { z = value; }}
    }
 
    /*
       * Initialisierung des Makrobefehls.
       */
  public SPE() : base(@"spe", @"Kopiert und verschiebt ausgewählte Bleche im Stahlprofileditor")
  {
  }
  
  /*
   * Einsprungsfunktion des Makros
   */
  public override void Execute(IExecuteCommandContext context)
  {
   System.Windows.Forms.MessageBox.Show(this.TooltipText, this.CommandName);
   
   Dyz dyz = new Dyz();
   MacroTools.EditValue( dyz);
   XVector3d delta = new XVector3d( 0, dyz.Y, dyz.Z);
   
   IDocObjectCollection beams = context.TargetDocument.GlobalSelection.GetObjects( typeof( Beam ));
   if( beams.Count == 0)
   {
    System.Windows.Forms.MessageBox.Show("Es sind keine Bleche ausgewählt.");
    return;
   }
   
   foreach( Beam beam in beams)
   {
      Beam copy = Beam.CreateNamed( context.TargetDocument );
      copy.Dicke = beam.Dicke;
     
      XPoint3d pntStart = beam.Anfangsknoten.Punkt;
      XPoint3d pntEnd = beam.Endknoten.Punkt;
     
      Node nodeBegin = Node.Find( context.TargetDocument, pntStart + delta);
      if( nodeBegin == null)
      {
         nodeBegin = Node.CreateNamed( context.TargetDocument, pntStart + delta );
         context.TargetDocument.AddObject( nodeBegin );
    }
     
      Node nodeEnd = Node.Find( context.TargetDocument, pntEnd + delta);
      if( nodeEnd == null)
      {
     nodeEnd = Node.CreateNamed( context.TargetDocument, pntEnd + delta);
     context.TargetDocument.AddObject( nodeEnd );
      }
     
      copy.Anfangsknoten = nodeBegin;
      copy.Endknoten = nodeEnd;
     
      context.TargetDocument.AddObject( copy );
   }
  }
 }
}

--

Kommentare sind geschlossen

Kalender

<<  Mai 2012  >>
MoDiMiDoFrSaSo
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

View posts in large calendar