cancel
Showing results for 
Search instead for 
Did you mean: 

Swept Volume Creation with API

Creator
Creator

Hello,

 

it is possible to Create a swept volume with API? How does it work?

 

I was trying...but i have only created the volume in the object tree, not as a "real" 3d component.

 

Dim SweptCreationData As New TxSweptVolumeCreationData()

Dim SweptVolume As TxSweptVolume = Nothing

SweptVolume = TryCast(Operation, ITxSweptVolumeHoldingObject).CreateSweptVolume(SweptCreationData)

SweptVolume.Accuracy = VolumeAccuracy

SweptVolume.Clearance = VolumeClearance

SweptVolume.Name = Robot.Name & "_" & Operation.Name & "_" & VolumeAccuracy & "mm"

Dim sweptVolumeCalculationData As New TxSweptVolumeCalculationData() With {.AutoInflateSweptVolume = TxApplication.Options.Motion.AutoInflateSweptVolumes}

Try

SweptVolume.Calculate(sweptVolumeCalculationData, ?CallBack?)

SweptVolume.Lock()

Try

SweptVolume.Color = New TxColor(SweptVolume.Color) With {.Transparency = 0.7}

Catch ex As System.Exception

End Try

Catch ex As TxSweptVolumeCalculationFailedException

SweptVolume.Delete()

'LOG
End Try

 

Did i missed something?

 

3 REPLIES

Re: Swept Volume Creation with API

Siemens Phenom Siemens Phenom
Siemens Phenom

Hello,

 

For the "Callback" you can try the following.

 

Sorry I have only some C# code.

 

{

TxSweptVolume_MayProceedCalculation ProceedCallback = new           TxSweptVolume_MayProceedCalculation(Proceed);
sv.Calculate(calcData, ProceedCallback);

}

 

private bool Proceed(int i)
{
return true;
}

 

Best regards

Patrick

 

Re: Swept Volume Creation with API

Creator
Creator

For some reason it's not working... (Callback function is inside the code)

 

the volume is created in the physikal root, but no 3D Rep is created.

 

Could you maybe provide a working example?

Re: Swept Volume Creation with API

Siemens Phenom Siemens Phenom
Siemens Phenom

Hello EDAG-PS,

 

Creation of swept volume is possible via our API.

 

Create SV is done via "CreateSweptVolume" method of ITxSweptVolumeHoldingObject object.

ITxSweptVolumeHoldingObject is implemented only by a few model objects:

  • robotic compound operations - weld, continuous feature, generic robotic;

 

  • object flow operation;

 

 

  • robotic program - not available for Process Simulate on Teamcenter.

 

 

The persistency of swept volumes is related to the operation/robotic program (deleting the holding object will delete also the swept volume).

If you don’t have a suitable operation, you need to create a dummy operation just for this purpose. (for ex. weld operation under the operation root).

To calculate the swept volume (add 3D), you need to create a TxSweptVolumeCalculationData that is a collection of TxObjectSweptVolumeCalculationData objects (object and list of locations).

If you want to create a swept volume for a robot simulated by operation, you need to run the simulation and for each TimeIntervalReached event to gather the locations of all the entities of the robot (GetAllDescendants method).

When the simulation ends, then create a TxSweptVolumeCalculationData, that will consists of  TxObjectSweptVolumeCalculationData for each entity of the robot and the robot itself. So at any simulation interval you will know what is the location of the robot entities.

 

private System.Collections.Hashtable objHash = new Hashtable();
private TxWeldOperation weldOp = null;

private void CreateSweptVolume()
{
objHash.Clear();
                weldOp = TxApplication.ActiveSelection.GetItems()[0] as TxWeldOperation;
TxSimulationPlayer player = new TxSimulationPlayer();
                player.SetOperation(weldOp);
                player.TimeIntervalReached += player_TimeIntervalReached;
                player.SimulationEndedForward += player_SimulationEndedForward;
                player.PlayWithoutRefresh();
}


        void player_TimeIntervalReached(object sender, TxSimulationPlayer_TimeIntervalReachedEventArgs args)
        {
            //Add also the attached objects if you need (the gun for example)            
            TxRobot rob = weldOp.Robot as TxRobot;
            TxObjectList children = rob.GetAllDescendants(new TxTypeFilter(typeof(ITxLocatableObject)));
            foreach(ITxLocatableObject child in children)
            {
                if (!objHash.ContainsKey(child))
                {
                    //if no data was added for that object (child) create new data
                    TxObjectSweptVolumeCalculationData osData = new TxObjectSweptVolumeCalculationData(child);
                    osData.AddTransformation(child.AbsoluteLocation);
                    objHash.Add(child, osData);
                }
                else
                {
                    //Get the data and add a new transformation
                    TxObjectSweptVolumeCalculationData osData = objHash[child] as TxObjectSweptVolumeCalculationData;
                    osData.AddTransformation(child.AbsoluteLocation);
                }
            }
        }

void player_SimulationEndedForward(object sender, TxSimulationPlayer_SimulationEndedForwardEventArgs args)
        {
            TxSimulationPlayer player = sender as TxSimulationPlayer;
            player.TimeIntervalReached -= player_TimeIntervalReached;
            player.SimulationEndedForward -= player_SimulationEndedForward;
            player.Rewind();


            TxRobot rob = weldOp.Robot as TxRobot;
            TxSweptVolumeCreationData svCredata = new TxSweptVolumeCreationData();
            TxSweptVolume sv = weldOp.CreateSweptVolume(svCredata);

            TxSweptVolumeCalculationData data = new TxSweptVolumeCalculationData();

            foreach(ITxLocatableObject locObj in objHash.Keys)
            {
                data.AddObjectData(objHash[locObj] as TxObjectSweptVolumeCalculationData);
            }
           
            sv.Calculate(data, MayProceed);
            sv.Lock();
        }

 

The MayProceed logic. In general this call-back has a meaning to:
a) keep UI alive (call to DoEvents method)

b) update progress (if you have a progress-bar or some label)

c) Force stop the generation (if you have a stop button)

If you don't need special handling for this just return "true".

It should be taken in account that creation of a swept volume might be time-consuming therefore such call-back is needed (at least for making UI responsive)

 

Best Regards,

DianaG