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: 

iLogic to change sheet name to equal Part Number.

58 REPLIES 58
SOLVED
Reply
Message 1 of 59
mstumbo
7157 Views, 58 Replies

iLogic to change sheet name to equal Part Number.

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,

 

 

 

 
58 REPLIES 58
Message 21 of 59
Stansteel
in reply to: rjay75

Could it be pulled from the Revision Table?
Message 22 of 59
rjay75
in reply to: Stansteel

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.

Message 23 of 59
Stansteel
in reply to: rjay75

1st Column.
Message 24 of 59
rjay75
in reply to: Stansteel

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
in reply to: rjay75

WOW! Brilliant! I'd like to shake your hand.
Message 26 of 59
Stansteel
in reply to: Stansteel

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
Message 27 of 59
rjay75
in reply to: Stansteel

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

Message 28 of 59
Stansteel
in reply to: rjay75

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.
Message 29 of 59
rjay75
in reply to: Stansteel

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

 

 

 

Message 30 of 59
Stansteel
in reply to: rjay75

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.
Message 31 of 59
rjay75
in reply to: Stansteel

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.
Message 32 of 59
Stansteel
in reply to: Stansteel

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.
Message 33 of 59
rjay75
in reply to: Stansteel

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
in reply to: rjay75

That did it! Thank you so much for your help! This saved us time and headache. I really appreciate it!
Message 35 of 59
Dopey1993
in reply to: rjay75

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! 

Message 36 of 59
MechMachineMan
in reply to: Dopey1993

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
in reply to: MechMachineMan

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

Message 38 of 59
rjay75
in reply to: Dopey1993

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
in reply to: rjay75

this is what i cant get to work 

 

Message 40 of 59
Dopey1993
in reply to: rjay75

This wont work

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

Post to forums  

Autodesk Design & Make Report