kDataDropIOMechanism

kDataDropIOMechanism

dylanTEV9W
Advocate Advocate
364 Views
5 Replies
Message 1 of 6

kDataDropIOMechanism

dylanTEV9W
Advocate
Advocate
Hi everyone, 

I'm trying to run this .stl translator sample but I'm running into a small issue.
it seems to be that a global variable called kDataDropIOMechanism is required I've seen it referenced in
several other places but none of them seem to mention what it is. If anyone can tell me what it is I'd really
appreciate it. Thanks in advance for any help!

Sub ImportFunc() ' Set STL translator's CLSID and STL file name. Dim strCLSID As String Dim strFileName As String strCLSld = "{81CA7D27-2DBE-4058-8188-9136F85FC859}" strFileName = "C:\Part1.stl" Dim oAddIns As ApplicationAddIns Set oAddIns = ThisApplication.ApplicationAddIns ' Find the Rhino translator, get the CLSID and activate it. Dim oTransAddIn As TranslatorAddIn Set oTransAddIn = oAddIns.ItemById(strCLSld) oTransAddIn.Activate ' Get the transient object and take it as a factory to produce other objects Dim transientObj As TransientObjects Set transientObj = ThisApplication.TransientObjects ' Prepare the first parameter for Open(), the file name Dim file As DataMedium Set file = transientObj.CreateDataMedium file.FileName = strFileName ' Prepare the second parameter for Open(), the open type. Dim context As TranslationContext Set context = transientObj.CreateTranslationContext context.Type = kDataDropIOMechanism ' Prepare the 3rd parameter for Open(), the options. Dim options As NameValueMap Set options = transientObj.CreateNameValueMap options.Value("SaveComponentDuringLoad") = False options.Value("SaveLocationIndex") = 0 options.Value("ComponentDestFolder") = "" options.Value("ImportUnit") = 1 options.Value("ImportColor") = True options.Value("ImportColorIndex") = 0 ' Prepare the fourth parameter for Open(), the final document. Dim sourceObj As Object ' Open the STL file. oTransAddIn.Open file, context, options, sourceObj End Sub

 

0 Likes
Accepted solutions (1)
365 Views
5 Replies
Replies (5)
Message 2 of 6

JamieVJohnson2
Collaborator
Collaborator

kDataDropIOMechanism is IOMechanismEnum with Value 13058.  its brothers are FileBrowse, PasteSpecial, and Unspecified.  Knowing that, it is most likely the drop portion of a drag and drop command sequence.  This is where the user click-drags an object, the do-drag event fires off, and the object is loaded into memory, then when a command that accepts the object type and the drag&drop's drop event (both event and object type), it will do work on the dropped object.

 

 

Jamie Johnson : Owner / Sisu Lissom, LLC https://sisulissom.com/
0 Likes
Message 3 of 6

dylanTEV9W
Advocate
Advocate

Any idea why it might be constantly throwing an error? Do I need to define it as a class or something?

0 Likes
Message 4 of 6

JamieVJohnson2
Collaborator
Collaborator
Accepted solution

It doesn't appear that you are performing an operation with drag-drop.  You probably want the other option kFileBrowsIOMechanism, as you are opening a file right?  Trying to guess from your code snippet...  I see that you copied directly from the Sample code, take a look at the Sample code for the DXF translator as well.  You will start to see a pattern for your use case.

 

 Also if you are intending a drag-n-drop operation, make sure the object is actually populated in-memory during the drop command.  It could be throwing an error because the object is 1 missing, or 2 the wrong object.

Jamie Johnson : Owner / Sisu Lissom, LLC https://sisulissom.com/
0 Likes
Message 5 of 6

dylanTEV9W
Advocate
Advocate

Okay I will try modifying the code with kFileBrowseIOMechanism and see how it works. Thanks for the help, I really appreciate you taking the time to explain that to me!

0 Likes
Message 6 of 6

dylanTEV9W
Advocate
Advocate

I've gotten it mostly working after replacing kDataDropIOMechanism with the kFileBrowseIOMechanism enum code. I've been trying to automate opening an .obj file in inventor, after some experimentation I found that simply using the basic open function did the trick for me.

0 Likes