Click or drag to resize

Creating Excitations

The Examples Below show how to create Differnt Types of Excitations.

Create a Current Density Source
# Python Script, API Version = V251
# Import EMA API
import clr, os
_refs, _refcount = clr.References, 0
_install_path = os.environ.get("EMA2025R1_DIR") # Change this to your local EMC Plus install directory.
_api_path = "ema3d.Api.V25.dll" # This should be the name of your EMC Plus API DLL.
for _ref in _refs:  # Check list of references, see how many EMC Plus API references are currently added.
    if "ema3d.Api" in _ref.FullName:
        _refcount += 1

if _refcount == 0:  # No references, add absolute reference
    clr.AddReferenceToFileAndPath(os.path.join(_install_path,_api_path))
    _refcount += 1
if _refcount == 1:  # 1 reference, add relative reference
    clr.AddReferenceToFileAndPath(_api_path)

from ema3d.Api.V25.Core.Excitation import CurrentDensity, CurrentDensityType

curve = Window.ActiveWindow.Document.MainPart.Curves[0]
doc = Window.ActiveWindow.Document

current_density = CurrentDensity.Create(curve)
current_density.CurrentType = CurrentDensityType.Electric
current_density.DisplayName = "Hello World Current Density"
current_density.IsReversed = True

print(CurrentDensity.GetByDisplayName("Hello World Current Density", doc))
Create an Antenna Source
# Python Script, API Version = V251

import clr
apipath = "ema3d.Api.V25.dll"
clr.AddReferenceToFileAndPath(apipath)

import ema3d.Api.V25.Core as Core
import ema3d.Api.V25.Core.Domain.Domain as Domain
from ema3d.Api.V25.Core.Excitation import AntennaSource
from ema3d.Api.V25.Cabling import SegmentLocation
from ema3d.Api.V25.Core.Signals import SineSignal
from SpaceClaim.Api.V251.Geometry import IHasTrimmedCurve

clr.AddReference("System.Core")
from System.Collections.Generic import HashSet

# get document
doc = Window.ActiveWindow.Document

# create domain
domain = Domain.GetInstance(doc)
Domain.ResetDomainBounds(domain)

# create line
start = Point.Create(MM(0), MM(0), MM(0))
end = Point.Create(MM(50), MM(50), MM(50))
line = SketchLine.Create(start, end)
design_curve = line.CreatedCurves[0]
design_curve_set = HashSet[IHasTrimmedCurve]({design_curve})

# create antenna source
segment_location = SegmentLocation.CreateRelative(design_curve, .5)
antenna = AntennaSource.Create(doc, design_curve_set, segment_location)
antenna.DisplayName = "HelloAntenna"

# Get Antenna by display name
fetched_antenna = AntennaSource.GetByDisplayName("HelloAntenna", doc)[0]

# Attach Sine Signal
sine_signal = SineSignal.Create(doc)
sine_signal.AttachTo(fetched_antenna)

# Refresh Stage to show EMA Tree
Solution.Stages.SetStage("EMA3D")