It is currently Sat May 25, 2013 1:36 pm

All times are UTC





Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Mon Sep 27, 2010 11:21 am 
Offline
MCAD Lurker

Joined: 27 Sep 2010
Posts: 3
Country: United Kingdom
State: Non US/CAN Resident
CAD System: Inventor
Hi All,

I'm a new user of Inventor - and an even newer user of iLogic / VB

Just wondered if anybody had any snippets to help me export a hole table in a drawing please? (to a text file)

I've managed to find the bits and pieces of VB code through the advanced programming help in Inventor, but I am failing in putting it all together!!

Any help would be really appreciated!

Many Thanks,

Tom


Share on FacebookShare on TwitterShare on DiggShare on DeliciousShare on TumblrShare on Google+
Top
 Profile  
 
PostPosted: Tue Sep 28, 2010 9:02 pm 
Offline
MCAD Contributer
User avatar

Joined: 10 Sep 2007
Posts: 116
Country: France
State: Non US/CAN Resident
CAD System: Inventor
Tom,

You can begin with this code :

Code:
Sub exportHoleTable()
    ' Set the active drawing document
    Dim oDrwDoc As DrawingDocument
    Set oDrwDoc = ThisApplication.ActiveDocument
    ' Set the active sheet
    Dim oSheet As Sheet
    Set oSheet = oDrwDoc.ActiveSheet
    ' Set HoleTables collection
    Dim oHoleTables As HoleTables
    Set oHoleTables = oSheet.HoleTables
    ' Export first holes table in Temp folder
    Call oHoleTables.Item(1).Export("c:\temp\myHoleTable.txt", kTextFileTabDelimitedFormat)
End Sub

_________________
Christophe S....t
Dev. App. Eng.


Top
 Profile  
 
PostPosted: Wed Sep 29, 2010 10:00 am 
Offline
MCAD Lurker

Joined: 27 Sep 2010
Posts: 3
Country: United Kingdom
State: Non US/CAN Resident
CAD System: Inventor
Thanks nomutt! Works perfectly!

I wasn't far off with my code! I didn't include the oSheet.HoleTables and i missed the Item(1) in the Export!

Thanks for you help!

Tom


Top
 Profile  
 
PostPosted: Fri Oct 08, 2010 10:24 am 
Offline
MCAD Lurker

Joined: 27 Sep 2010
Posts: 3
Country: United Kingdom
State: Non US/CAN Resident
CAD System: Inventor
I descided that the hole table needs to be created from the assembly and outputed to excel. There it will be sorted and re-read by inventor. My Vb code so far for sorting the excel sheet is:

Public Sub excelopensorttest()

'Code for running excel macro in vbs


Dim xlApp
Set xlApp = CreateObject("excel.application")

Dim xlWkb
Set xlWkb = xlApp.Workbooks

Dim xlWkbs
Set xlWkbs = xlWkb.Open("z:\test1.xlsm")

Dim xlWkbsa As Workbook
Set xlWkbsa = xlWkbs


xlApp.Visible = False


Range("A1:B500").Select
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

xlWkbsa.Save
xlWkbsa.Close
xlApp.Quit

Set xlWkbsa = Nothing
Set xlWkbs = Nothing
Set xlWkb = Nothing
Set xlApp = Nothing


End Sub


It leaves an instance of excel open and I cant workout why? Does anyone have any ideas?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
POWERED_BY