iLogic to change sheet name to equal Part Number.

iLogic to change sheet name to equal Part Number.

Anonymous
Not applicable
10,194 Views
58 Replies
Message 1 of 59

iLogic to change sheet name to equal Part Number.

Anonymous
Not applicable

I would like to have an iLogic rule that changes the active sheet name to the Models Part Number property.

 

I tried ActiveSheet.name = iProperties.Value("Project", "Part Number"), but

 

get an Error: Property 'Name' is 'ReadOnly'.

 

 

Any help would be greatly appreciated.

 

Thanks,

 

 

 

 
0 Likes
Accepted solutions (1)
10,195 Views
58 Replies
Replies (58)
Message 21 of 59

Stansteel
Enthusiast
Enthusiast
Could it be pulled from the Revision Table?
0 Likes
Message 22 of 59

rjay75
Collaborator
Collaborator

Yes, if you have a revision table on the drawing it could be pulled from there. What column is the Revision number at in the table.

0 Likes
Message 23 of 59

Stansteel
Enthusiast
Enthusiast
1st Column.
0 Likes
Message 24 of 59

rjay75
Collaborator
Collaborator

Change the line:

 

prtRev = modelDoc.PropertySets("Summary Information").Item("Revision Number").Value

 

With

 

prtRev = ""

If dwgSheet.RevisionTables.Count > 0 Then

  If dwgSheet.RevisionTables(1).RevisionTableRows.Count > 0 Then

    Dim rows As RevisionTableRows = dwgSheet.RevisionTables(1).RevisionTableRows

    prtRev = rows(rows.Count)(1).Text 'Get the text of the first column of the last row

  End If

End If

Message 25 of 59

Stansteel
Enthusiast
Enthusiast
WOW! Brilliant! I'd like to shake your hand.
0 Likes
Message 26 of 59

Stansteel
Enthusiast
Enthusiast
Any way to get the sheet number of the multiple assembly drawings into my title block? In the browser, the sheet names show up at "SHEET 1" or "SHEET 2". In my title block I have a prompted entry where I input the sheet number where it'll show up as just a number. Nate
0 Likes
Message 27 of 59

rjay75
Collaborator
Collaborator

Sure, is there what is the text of the prompt. Is there more than one field. Like 1 of 2.

0 Likes
Message 28 of 59

Stansteel
Enthusiast
Enthusiast
Just one field. I know there is an automated way to show say "3 of 6", but this is a function of all drawing sheet. In this case, I only want the assembly sheets where we've placed "SHEET 1" in the browser name. My title block has a box labled "Sheet" where I want it to be simply "1" or "2" and so on.
0 Likes
Message 29 of 59

rjay75
Collaborator
Collaborator

After the line:

 

sheetOf = String.Format(" Sheet {0}", sheetNames(prtNumber)(1))

 

Add:

If Not dwgSheet.TitleBlock Is Nothing Then
  tb = dwgSheet.TitleBlock
  If tb.Definition.Sketch.TextBoxes.Count > 0 Then
    For Each txtBox As TextBox In tb.Definition.Sketch.TextBoxes
      If txtBox.FormattedText.Contains("Sheet</Prompt>") Then
        tb.SetPromptResultText(txtBox, sheetNames(prtNumber)(1))
      End If
    Next
  End If
End If

 

 

 

0 Likes
Message 30 of 59

Stansteel
Enthusiast
Enthusiast
Doesn't seem to do anything. Do I need to match the text to what I have in my title block? Attached is a picture of the text box.
0 Likes
Message 31 of 59

rjay75
Collaborator
Collaborator
Didn't see a picture but yes the text needs to match. That's how it locates the correct textbox to add the text to. Currently its looking for "Sheet</Prompt>" So change that to whatever text you have with </Prompt> on the end.
0 Likes
Message 32 of 59

Stansteel
Enthusiast
Enthusiast
No luck. The text I have in my title block as a prompted entry is "Sheet #". So I changed the code to be "Sheet #<\Prompt>)". I tried taking the space and pound symbol off too. Nothing happens.
0 Likes
Message 33 of 59

rjay75
Collaborator
Collaborator

As a test try setting it to:

 

If txtBox.FormattedText.Contains("Sheet #") Then

 

to see what happens.

 

Also noticed a trailing ')' in your string that shouldn't be there.

Message 34 of 59

Stansteel
Enthusiast
Enthusiast
That did it! Thank you so much for your help! This saved us time and headache. I really appreciate it!
0 Likes
Message 35 of 59

Dopey1993
Enthusiast
Enthusiast

I really like this rule is save me a lot of time however i would like to replace the Revision Number with the description of the part ive messed with it a liltle bit but it keeps kicking out errors. thanks! 

0 Likes
Message 36 of 59

MechMachineMan
Advisor
Advisor

Dopey.... Just look further back in this thread. Rjay posted a bunch of variations including one with descriptions.


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 37 of 59

Dopey1993
Enthusiast
Enthusiast

It works great for an assembly file but I can't get it to work on a part file?

0 Likes
Message 38 of 59

rjay75
Collaborator
Collaborator

Can post or attached what you changed? In the original rule there was nothing specific to assemblies so it should work for both.

 

Thanks

Message 39 of 59

Dopey1993
Enthusiast
Enthusiast

this is what i cant get to work 

 

0 Likes
Message 40 of 59

Dopey1993
Enthusiast
Enthusiast

This wont work

0 Likes