DigiPara Liftdesigner LDX API
Loading...
Searching...
No Matches
Copy user component

API method: ILDXComp5.MemCopyTo

Treename: Shaft0.Components.LD API Example.

 ' from Samples/Src/LDXAPIExamples/Example_LDXUserComp.vb

    <APIHelpAttribute(APIHelpModes.FireCalcModel Or APIHelpModes.LoadLD3File, {APIHelpModes.InputParaLDXDoc}, "Shaft0.Components.LD API Example.", "LDXComp~MemCopyTo", "Copy user component")>
 Public Shared Sub CopyUserComponent(ByRef ldxDocument As DigiPara.LDX.LDXDocument)

     If ldxDocument.GetLDXObject("Shaft0.Components.LD API Example.") Is Nothing Then
         MsgBox("User component not found! Please reload the relevent .ld3 object.")
         Exit Sub
     End If

     Dim ldxComponents As DigiPara.LDX.LDXComponents = DirectCast(ldxDocument.GetLDXObject("Shaft0.Components.").LDXType, DigiPara.LDX.LDXComponents)
     ' The new component name
     Dim newUserComponentName = "LD API Example - Clone"
     ' Add a new user component
     Dim newLDXObject As DigiPara.LDX.LDXObject = ldxComponents.Add(newUserComponentName)
     Dim ldxUserComp As DigiPara.LDX.LDXUserComp = DirectCast(ldxDocument.GetLDXObject("Shaft0.Components.LD API Example.").LDXType, DigiPara.LDX.LDXUserComp)
     ' Copy the old user components values to the new one 
     ldxUserComp.Comp.MemCopyTo(newLDXObject.Comp)
     ' Set the new user component's name
     DirectCast(newLDXObject.LDXType, DigiPara.LDX.LDXUserComp).Name = newUserComponentName
     ' Set the new user component's inward displacement and color
     newLDXObject.SetValue("Y0", 2280)
     newLDXObject.Comp.VisualMaterial.PGOGL_RID64 = 11000
 End Sub