Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

64 bit VBA

5 REPLIES 5
Reply
Message 1 of 6
Anonymous
381 Views, 5 Replies

64 bit VBA

I have a macro that worked great in IV 2008 and prior. IV 2009 64 bit is a problem. Most things work but I am having crash problems with accessing Units of measure and Sheet metal syle material name. It will work for the first part but as it brings up the second it freezes and then crashes hard.

I use the following to get to the material name:

Dim oSheetMetalCompDef As SheetMetalComponentDefinition
Set oModel = ThisApplication.Documents.Open(ItemFilePath, False)
Set oSheetMetalCompDef = oModel.ComponentDefinition
TextBox5.Value = CStr(oSheetMetalCompDef.ActiveSheetMetalStyle.Material.Name)

The following fo Units of measure:

Dim oUOM As UnitsOfMeasure
Set oUOM = DocM.UnitsOfMeasure

' Obtain the Parameters collection
Dim oParamsU As Parameters
Set oParamsU = DocM.ComponentDefinition.Parameters

' Obtain the Model Parameters collection
Dim oModelParamU As ModelParameters
Set oModelParamU = oParamsU.ModelParameters

' Get document units
ModelUnit = oUOM.GetStringFromType(kDefaultDisplayLengthUnits)
5 REPLIES 5
Message 2 of 6
Anonymous
in reply to: Anonymous

Can you provide a full sample that demonstrates your problem? I tested the
code from your post but it works fine for me.
--
Brian Ekins
Autodesk Inventor API
Message 3 of 6
Anonymous
in reply to: Anonymous

I know I am a bit of a newbe but here it is. The purpose is to get reference numbers for sheet metal parts and show the thickness and material, qty and so on. The code works fine in 32 bit. In 64 bit it will bring up the first sheet metal part in the parts list ok and then on next it shows the second one and freezes and then crashes IV09. I have a column in the parts list for the file path. If this is still not enough please give me an email so I can send files for full functionality.


Private Sub GetSheetMetal()

Dim oDocNum, ProjNum, ItemNum, ItemFilePath As String

If a <> 0 And b <> 0 And c <> 0 Then

' Iterate through the contents of the parts list.

NextRow:
' Get the current row.
ItemFilePath = ""
Set oRow = oPartList.PartsListRows.Item(f)
oRowVis = oRow.Visible

If oRowVis Then
' If row is visible and is sheet metal then get file path

If oRow.Item(c).Value = "Sheet Metal" Then

ItemFilePath = CStr(oRow.Item(b).Value)
If ItemFilePath <> "" Then

' Get the sheet metal component definition. Because this is a part document whose
' sub type is sheet metal, the document will return a SheetMetalComponentDefinition
' instead of a PartComponentDefinition.
Dim oSheetMetalCompDef As SheetMetalComponentDefinition

ProjNum = oDrawDoc.PropertySets.Item("Design Tracking Properties").Item("PROJECT").Value
ItemNum = CStr(oRow.Item(a).Value)
oDocNum = oDrawDoc.PropertySets.Item("User Defined Properties").Item("Document number").Value
Set oModel = ThisApplication.Documents.Open(ItemFilePath, False)
Set oSheetMetalCompDef = oModel.ComponentDefinition

TextBox1.Value = CStr(oRow.Item(a).Value)
TextBox2.Value = oModel.DisplayName
TextBox3.Value = CStr(oRow.Item(d).Value)
TextBox4.Value = CStr(ProjNum & oDocNum & "-" & ItemNum)
TextBox5.Value = CStr(oSheetMetalCompDef.ActiveSheetMetalStyle.Material.Name _
& " " & oSheetMetalCompDef.ActiveSheetMetalStyle.Thickness)
f = f + 1
oModel.Close (False)
Set oSheetMetalCompDef = Nothing
Set oModel = Nothing

Exit Sub

Else

MsgBox ("File Path Not Present - Check Parts List Type")
f = f + 1
Exit Sub

End If

Else

f = f + 1
If f <= i Then
GoTo NextRow
Else
cmdOk.Enabled = False
Exit Sub
End If

End If

Else

f = f + 1
If f <= i Then
GoTo NextRow
Else
cmdOk.Enabled = False
Exit Sub
End If

End If

Else

MsgBox ("Check Parts List Type")
Exit Sub

End If

End Sub
Message 4 of 6
Anonymous
in reply to: Anonymous

Note: If I take out the material AND the thickness it works fine (Textbox5)
Message 5 of 6
Anonymous
in reply to: Anonymous

Without having a reproducable case I'm not sure what specific problem you're
running into. I created a test case that I think is similar to what you
have. Here's a modified version of your code and the files I used are
attached.

Private Sub GetSheetMetal()
Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument

Dim oPartsList As PartsList
Set oPartsList = oDrawDoc.ActiveSheet.PartsLists.Item(1)

' Iterate through the contents of the parts list.
Dim oRow As PartsListRow
For Each oRow In oPartsList.PartsListRows
' Make sure we're only using visible rows.
If oRow.Visible Then
If oRow.Item("Part Type") = "Sheet Metal" Then
' Get the sheet metal document.
Dim oSMDef As SheetMetalComponentDefinition
Set oSMDef =
oRow.ReferencedRows.Item(1).BOMRow.ComponentDefinitions.Item(1)

Dim oSMDoc As PartDocument
Set oSMDoc = oSMDef.Document

Dim ProjNum As String
Dim DocNum As String
ProjNum = oDrawDoc.PropertySets.Item("Design Tracking
Properties").Item("PROJECT").Value

Debug.Print CStr(oSMDef.ActiveSheetMetalStyle.Material.Name
_
& " " & oSMDef.ActiveSheetMetalStyle.Thickness)
End If
End If
Next
End Sub


--
Brian Ekins
Autodesk Inventor API
Message 6 of 6
Anonymous
in reply to: Anonymous

Thank you. It is what I needed as far as accessing the part from the partslist. I changed that in my code and it works great.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report