Message 1 of 6
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
Im just dipping into VB. net AddIns from usually using VBA macros and I'm strugging to get an existing macro working. The task is simple - obtaining the current active document and testing it for type but I just cant seem to find a way of using the .Activedocument property inherited from my macro:
So the code behind my form starts with that below, however the line oDoc = Inventor.activedocument is not being accepted.
Any ideas where I am going wrong please?
TIA
Imports Inventor
Public Class FrmPointsHarvest
Dim oDoc As Document
Private Sub FrmPointsHarvest_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' Set a reference to the active document.
oDoc = Inventor.activedocument
'if a part or assembly
Select Case oDoc.DocumentType
Case 12290
Part_Type = "IPT"
oPartDoc = oDoc
BtnHarvest.Enabled = True
Case 12291
Part_Type = "IAM"
oAssyDoc = oDoc
BtnHarvest.Enabled = True
Case Else
Part_Type = "Other"
BtnHarvest.Enabled = False
MsgBox(oDoc.DocumentType & " is Open. You must open an Inventor Part (.IPT) or Assembly (.IAM) file.", vbOKOnly)
Me.Close()
End Select
End Sub
I need the oDoc setting so I can subsequently extract 3D points from each part in the assy or part like this, but without a reference to oDoc Im stuck !
Public Sub Export3DSketchPoints(oDoc As Inventor.PartDocument)
'This sub extracts SKETCHPOINTS from a PART file
Set oDef = oDoc.ComponentDefinition
Dim o3DSketchs As Sketches3D
Dim o3DSketch As Sketch3D
Dim o3DSketchPoint As SketchPoint3D
Dim Pnt As Point
Set o3DSketchs = oDef.Sketches3D 'get all 3DSketches in this part
Dim nRow As Integer
nRow = 1
For Each o3DSketch In o3DSketchs 'each 3d sketch
For Each o3DSketchPoint In o3DSketch.SketchPoints3D
Set Pnt = o3DSketchPoint.Geometry
oSheet.Cells(nRow, 1) = conv(Pnt.X)
oSheet.Cells(nRow, 2) = conv(Pnt.Y)
oSheet.Cells(nRow, 3) = conv(Pnt.Z)
nRow = nRow + 1
Next o3DSketchPoint
Next o3DSketch
End Sub
Solved! Go to Solution.