Inventor Customization

Reply
Contributor
danmorick
Posts: 18
Registered: ‎01-27-2011
Message 1 of 5 (368 Views)
Accepted Solution

Edit filename of iAssembly Table Member in ilogic

368 Views, 4 Replies
02-15-2013 02:08 PM

Hi,

 

Can anyone show me how to edit the member name in an iassembly table using code?  The Part Number and Description iproperties are easy to handle.  But I am stuck on how to access the member name and edit it.  I guessed at some methods, but keep getting errors.

 

Thanks.

 

-Dan

ADN Support Specialist
xiaodong.liang
Posts: 1,190
Registered: ‎06-12-2011
Message 2 of 5 (319 Views)

Re: Edit filename of iAssembly Table Member in ilogic

02-27-2013 07:18 PM in reply to: danmorick

Hi,

 

Similar to iPart, the iAssembly is edited through the corresponding Excel table. Here is a small demo on how to create which could be start for you.

 

Public Sub CreateiAssemblyFactory()
    
    Dim oDoc As AssemblyDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    Dim odef As AssemblyComponentDefinition
    Set odef = oDoc.ComponentDefinition
    
    Dim oFactory As iAssemblyFactory
    Set oFactory = odef.CreateFactory
    
    Dim oWorkSheet As WorkSheet
    Set oWorkSheet = oFactory.ExcelWorkSheet
    
    Dim oCells As Range
    Set oCells = oWorkSheet.Cells
    
    ' Columns...
    oCells.Item(1, 2) = "HANDLE CAP:1:Include/Exclude"
    oCells.Item(1, 3) = "HANDLE CAP:2:Include/Exclude"
    oCells.Item(1, 4) = "LEVER ARM:1:Include/Exclude"
    oCells.Item(1, 5) = "Arbor_Frame:1:Grounding Status"
    oCells.Item(1, 6) = "d75"
    oCells.Item(1, 7) = "d92"
    
    ' Row 1 values...
    oCells.Item(2, 1) = "Arbor_Press-01"
    oCells.Item(2, 2) = "Include"
    oCells.Item(2, 3) = "Include"
    oCells.Item(2, 4) = "Include"
    oCells.Item(2, 5) = "Grounded"
    oCells.Item(2, 6) = "0.0 in"
    oCells.Item(2, 7) = "180.00000"
    
    ' Row 2 values...
    oCells.Item(3, 1) = "Arbor_Press-02"
    oCells.Item(3, 2) = "Include"
    oCells.Item(3, 3) = "Include"
    oCells.Item(3, 4) = "Include"
    oCells.Item(3, 5) = "Grounded"
    oCells.Item(3, 6) = "0.5 in"
    oCells.Item(3, 7) = "90.00000"
    
    ' Row 3 values...
    oCells.Item(4, 1) = "Arbor_Press-03"
    oCells.Item(4, 2) = "Exclude"
    oCells.Item(4, 3) = "Exclude"
    oCells.Item(4, 4) = "Exclude"
    oCells.Item(4, 5) = "Ungrounded"
    oCells.Item(4, 6) = "0.0 in"
    oCells.Item(4, 7) = "180.00000"

    Dim oWB As WorkBook
    Set oWB = oWorkSheet.Parent
    
    oWB.Save
    oWB.Close

End Sub

 



Xiaodong Liang
Developer Technical Services
Autodesk Developer Network

Contributor
danmorick
Posts: 18
Registered: ‎01-27-2011
Message 3 of 5 (303 Views)

Re: Edit filename of iAssembly Table Member in ilogic

03-01-2013 06:59 AM in reply to: xiaodong.liang

Xiaodong,

 

Thanks very much for that.  Unfortunately, I have my code as ilogic, not straight VB.NET.  So when I run this I get an error,

"Type 'WorkSheet' is not defined."  Is there a way that you can think of to do this in the ilogic environment?  My member name is always a formula of Part Number and Description iproperties, both of which I have in my table.

 

My alternative, I suppose, is to convert my code to pure vb.net and then proceed...

 

-Dan

ADN Support Specialist
xiaodong.liang
Posts: 1,190
Registered: ‎06-12-2011
Message 4 of 5 (274 Views)

Re: Edit filename of iAssembly Table Member in ilogic

03-10-2013 08:00 PM in reply to: danmorick

Hi,

 

you could declare the objects of Excel without type. I believe iLogic has import Excel reference, that is why there are some methods under the category Excel. The iLogic code below works well at my side.

 

 
    Dim oDoc As AssemblyDocument
     oDoc = ThisApplication.ActiveDocument
    
    Dim odef As AssemblyComponentDefinition
     odef = oDoc.ComponentDefinition
    
    Dim oFactory As iAssemblyFactory
     oFactory = odef.CreateFactory
    
    Dim oWorkSheet
     oWorkSheet = oFactory.ExcelWorkSheet
    
    Dim oCells
     oCells = oWorkSheet.Cells
    
    ' Columns...
    oCells.Item(1, 2) = "HANDLE CAP:1:Include/Exclude"
    oCells.Item(1, 3) = "HANDLE CAP:2:Include/Exclude"
    oCells.Item(1, 4) = "LEVER ARM:1:Include/Exclude"
    oCells.Item(1, 5) = "Arbor_Frame:1:Grounding Status"
    oCells.Item(1, 6) = "d75"
    oCells.Item(1, 7) = "d92"
    
    ' Row 1 values...
    oCells.Item(2, 1) = "Arbor_Press-01"
    oCells.Item(2, 2) = "Include"
    oCells.Item(2, 3) = "Include"
    oCells.Item(2, 4) = "Include"
    oCells.Item(2, 5) = "Grounded"
    oCells.Item(2, 6) = "0.0 in"
    oCells.Item(2, 7) = "180.00000"
    
    ' Row 2 values...
    oCells.Item(3, 1) = "Arbor_Press-02"
    oCells.Item(3, 2) = "Include"
    oCells.Item(3, 3) = "Include"
    oCells.Item(3, 4) = "Include"
    oCells.Item(3, 5) = "Grounded"
    oCells.Item(3, 6) = "0.5 in"
    oCells.Item(3, 7) = "90.00000"
    
    ' Row 3 values...
    oCells.Item(4, 1) = "Arbor_Press-03"
    oCells.Item(4, 2) = "Exclude"
    oCells.Item(4, 3) = "Exclude"
    oCells.Item(4, 4) = "Exclude"
    oCells.Item(4, 5) = "Ungrounded"
    oCells.Item(4, 6) = "0.0 in"
    oCells.Item(4, 7) = "180.00000"

    Dim oWB
     oWB = oWorkSheet.Parent
    
    oWB.Save
    oWB.Close


Xiaodong Liang
Developer Technical Services
Autodesk Developer Network

Contributor
danmorick
Posts: 18
Registered: ‎01-27-2011
Message 5 of 5 (266 Views)

Re: Edit filename of iAssembly Table Member in ilogic

03-11-2013 07:56 AM in reply to: xiaodong.liang

Excellent!  Yes, this is working for me.  Thanks so much for the assistance.

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Welcome to the new Autodesk Community!
If this is your first visit, click here to get started and make the most of the Community. Let us know what you think of the new experience in the Community Feedback Forum.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor

Twitter

Facebook

Blogs

Pinterest

Youtube