Announcements
Due to scheduled maintenance, the Autodesk Community will be inaccessible from 10:00PM PDT on Oct 16th for approximately 1 hour. We appreciate your patience during this time.
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: 

How to get static value in vba

9 REPLIES 9
Reply
Message 1 of 10
k14348
1066 Views, 9 Replies

How to get static value in vba

Sub DateChange()
    Dim oDoc As DrawingDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    Dim oRevTb As RevisionTable
    Set oRevTb = oDoc.ActiveSheet.RevisionTables.Item(1)
    
    Dim oLatestRow As RevisionTableRow
    Set oLatestRow = oRevTb.RevisionTableRows.Item(oRevTb.RevisionTableRows.Count)
    
    
    Dim oValue As RevisionTableCell
    Set oValue = oLatestRow.Item(3)
    
    oValue.FormattedText =? 'I need a static value
    
    
    
    
    
End Sub

What to write to get static value of revison table cell.

-karthikeyan

9 REPLIES 9
Message 2 of 10
Owner2229
in reply to: k14348

Here you go:

 

Sub DateChange()
    Dim oDoc As DrawingDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    Dim oRevTb As RevisionTable
    Set oRevTb = oDoc.ActiveSheet.RevisionTables.Item(1)
    
    Dim oLatestRow As RevisionTableRow
    Set oLatestRow = oRevTb.RevisionTableRows.Item(oRevTb.RevisionTableRows.Count)
    
    Dim oCell As RevisionTableCell
    Set oCell = oLatestRow.Item(3)
    
Dim oValue As String
oValue = oCell.Text End Sub
Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
Message 3 of 10
k14348
in reply to: Owner2229

Sub DateChange()
    Dim oDoc As DrawingDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    Dim oRevTb As RevisionTable
    Set oRevTb = oDoc.ActiveSheet.RevisionTables.Item(1)
    
    Dim oLatestRow As RevisionTableRow
    Set oLatestRow = oRevTb.RevisionTableRows.Item(oRevTb.RevisionTableRows.Count)
    
    
    Dim oCell As RevisionTableCell
    Set oCell = oLatestRow.Item(3)
    
    Dim oVal As String
    oVal = oCell.Text
    
    oCell.Text = oVal
      
End Sub

your code has some error. Please check . Above code also not working.

Message 4 of 10
Owner2229
in reply to: k14348

I can't see the issue in it. Both reading and writing to the cells is working for me.

Can you test the iLogic code below, instead of VBA?

Also, what are you trying to achieve? Read the value or write to it?

 

Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oRevTb As RevisionTable = oDoc.ActiveSheet.RevisionTables.Item(1)
Dim oLatestRow As RevisionTableRow = oRevTb.RevisionTableRows.Item(oRevTb.RevisionTableRows.Count)
Dim oCell As RevisionTableCell = oLatestRow.Item(3)
'Read the value Dim oVal As String = oCell.Text MsgBox(oVal)

'Write to it
oCell.Text = "something"

 

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
Message 5 of 10
k14348
in reply to: Owner2229

Hi,

   I have a Revision table cell with duplicate value.(If it is a duplicate value cell will be in blue color). Now i want to right click the cell and make it static value. Screen shot is attached. This i want to achieve it in vba. Already static value change ilogic program available in the forum. But my question is  y we r unable to achieve this in vba. After run vba program table should look like stat 2 attachment. not like stat11 attachment.

Message 6 of 10
Owner2229
in reply to: k14348

Well, I've looked into it and I couldn't find any way to do this.

Maybe someone from @autodesk could help.

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
Message 7 of 10
k14348
in reply to: Owner2229

okay thank you for your support.
Message 8 of 10
ekinsb
in reply to: k14348

Mike is correct, the API doesn't currently support the ability to get or set if a cell in a revision table is set to "Static".  It would be best to request this on the IdeaStation so the request doesn't get lost and it can be prioritized with other work.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 9 of 10
NachitoMax
in reply to: ekinsb

Hi

 

Don't know if this will help or not but.... I had some small issues with static values in a parts list so instead, I looped through the columns and changed the values that way. Maybe it could be a similar thing for the revision table? I haven't checked..

 

Here is my code

Private Const sColumnTitle As String = "DRAWING"



Dim oPartsList As PartsList Dim ic As Integer For ic = 1 To oSheet.PartsLists.Count Set oPartsList = oSheet.PartsLists.Item(ic) Next Dim i As Long For i = 1 To oPartsList.PartsListRows.Count Dim oRow As PartsListRow Set oRow = oPartsList.PartsListRows.Item(i) ' Iterate through each column in the row. Dim j As Long For j = 1 To oPartsList.PartsListColumns.Count ' Get the current cell. Dim oCell As PartsListCell Set oCell = oRow.Item(j) ' Check that the column isn't the quantity column. If oPartsList.PartsListColumns.Item(j).Title = sColumnTitle Then If oCell.Value = "N/A" Then oCell.Value = "" oCell.Static = False End If End If Next Next

Cheers

 

Nacho

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


Message 10 of 10

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

Post to forums  

Autodesk Design & Make Report