Save Files to Folder

Save Files to Folder

Anonymous
Not applicable
983 Views
2 Replies
Message 1 of 3

Save Files to Folder

Anonymous
Not applicable

I have a Vb and Ilogic mash up that I need help make save the files into the right location.

The macro adds the assembly name to a custom Iproperty on all the Sheet metal parts and creates a folder called "Drawings, the assembly name" using:

Dim customPropSet As PropertySet
Dim invPartDoc As PartDocument
Set invPartDoc = ThisApplication.ActiveDocument
Set customPropSet = invPartDoc.PropertySets.Item("User Defined Properties")
Dim AssemblyName As Property
On Error Resume Next

Set AssemblyName = customPropSet.Add(oAsmName, "AssemblyName")

and:

Dim oFolder As String
    oFolder = oPath & "\" & "Drawings " & oAsmName
    
    'Check for the DXF folder and create it if it does not exist
    If Len(Dir(oFolder, vbDirectory)) = 0 Then
        MkDir oFolder

The macro then runs the Ilogic rule on the parts which creates a drawing of the part and I need to save that drawing to the folder and I'm trying to use:  which isn't working but it's not throwing error codes either it just saves the drawing next to the part like it did before I added this

oDrawDoc = ThisApplication.ActiveDocument
Dim oRef as Document
 oRef = oDrawDoc.ReferencedDocuments.Item(1)
Dim New_Folder As String = ThisDoc.Path
Dim AsmName As String
AsmName = oRef.PropertySets.Item(4).Item("AssemblyName").Value
strNew = New_Folder & "\" & "Drawings " & AsmName
ThisDoc.Document.SaveAs(strNew & filename, True)
0 Likes
Accepted solutions (1)
984 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable

I forgot I had a line ignoring errors for a different part of the code.  The Ilogic comes with an error saying:

Error in rule: RuleForDrawing, in document: TAY004-E101-I613_A .dwg

The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))

And the more info says:

System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
at Inventor._DocumentClass.SaveAs(String FileName, Boolean SaveCopyAs)
at LmiRuleScript.Main()
at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

I really appreciate any help.

0 Likes
Message 3 of 3

Anonymous
Not applicable
Accepted solution

I was missing a couple \ 

working code:

Dim New_Folder As String = ThisDoc.Path
Dim AsmName As String
AsmName = oRef.PropertySets.Item(4).Item("AssemblyName").Value
strNew = New_Folder & "\" & "Drawings " & AsmName & "\" & Gauge_Name & " " & oMaterial
New_Name = ThisDoc.FileName
ThisDoc.Document.SaveAs(strNew & "\" &  New_Name & ".idw",(True))
0 Likes