Ways for cables to disappear

Hi all, I don’t know if anyone else remembers a Cable physics module from VC who was used to do connecting cables.
Specifically, the problem I’m having is this, I’m currently working on the fitting part of a mouthpiece machine, and I need to connect the retractable straps to the body of the mouthpiece, which involves a straight line to an arc, and I’m considering that VC has a Cable module, so I’m ending up using using using this module to do this. After finalizing this, I was ready to proceed with my first step to make the rope able to generate and disappear in a loop, but at this point I ran into trouble, I used the code to generate the cable component ‘201mm’, the code is as follows:

from vcScript import *

def OnReset():
  global a
  #a.delete()
  pass

def OnRun():
  global a
  #a = part.clone()
  a = app.cloneComponent(part) 
  delay(3)
  #a.delete()


app = getApplication()
part = app.findComponent('201mm')
a = None


What’s causing me trouble is the part that makes the string disappear, when I choose to delete it directly using the delete() function, VC reports an error

Unhandled exception occurred:EXCEPTION_ACCESS_VIOLATION (code: 0xC0000005)
 0# 0x00007FFB19F23099 in VisualComponents_Revolution
 1# 0x00007FFB22322A6E
 2# 0x00007FFB22321E71
 3# DllCanUnloadNowInternal in clr
 4# 0x00007FFB22321D2E
 5# DllCanUnloadNowInternal in clr
 6# enableCppUnhandledExceptionDispatcher in VisualComponents_Revolution
 7# _chkstk in ntdll
 8# RtlFindCharInUnicodeString in ntdll
 9# KiUserExceptionDispatcher in ntdll
10# rDLinkList::GBegin in Revolution

Then the VC crashes or the Python module fails, I’m not sure what’s going on here, but I really need to know if my idea is feasible or if there’s an alternative to my current solution.
Anyone’s response is welcome, thanks in advance!

I heard there is a bug in VC 4.9.2 and earlier which causes such crash if a component with a physics cable is cloned and then gets deleted for any reason. Since it is a known bug it might be fixed in upcoming release.

A workaround is to recreate the physics cable with code and never attempt to clone it.

1 Like

Thanks for the reply, do you mean, create the new component with CreatComponent() and then create the Cable with createBehaviour()? ummm, sounds like a new direction, I’ll give it a try. Thanks again!

To update this topic, I’ve done the looping part so far, and I’ve found that if I remove the Cable behavior before deleting the entire component, then deleting the entire component doesn’t result in an error (I’ve only tested the case where the deletion code is placed in OnReset). I have put the code below for possible needs.


from vcScript import *
import vcMatrix
def OnReset():
  global a,temp,por
  #a.delete()
  a.Visible = False
  print por

  por.delete()
  a.delete()
  temp.append(a)


def OnRun():
  #app.findComponent('demo').delete()
  global a,m,n,b,c,temp,por
  #a = part.clone()
  #a = app.cloneComponent(part) 
  m = vcMatrix.new()
  n = vcMatrix.new()
  m.rotateAbsX(180)
  m.translateAbs(0,0,200.999+17.5)
  a = app.createComponent()
  a.Name = 'demo'
  por = a.createBehaviour('rPhysicsRope','PhysicsCable')
  a.PositionMatrix = partframe
  por.Thickness = 1
  n1 = a.findNode('Pin_1')
  n2 = a.findNode('Pin_2')
  print 'n=[',n.P.X,n.P.Y,n.P.Z,n.WPR.X,n.WPR.Y,n.WPR.Z,']'
  print 'm=[',m.P.X,m.P.Y,m.P.Z,m.WPR.X,m.WPR.Y,m.WPR.Z,']'
  a.rebuild()
  n1.PositionMatrix = n
  n2.PositionMatrix = m
  a.rebuild()



app = getApplication()
part = app.findComponent('201mm')
partframe = part.PositionMatrix
a = None
temp = []



comp = getComponent()