Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Sclae on tile block with Ilogic

srionde
Enthusiast

Sclae on tile block with Ilogic

srionde
Enthusiast
Enthusiast

Hello all,

 

I am using this code to put scale on block and use before save document as trigger, however if I have more than one page on my idw file, everytime i  save, I always go back to the last page.

Is this anyway to keep same page ?

 

 

For Each Osheet In ThisApplication.activedocument.sheets
    ActiveSheet=ThisDrawing.Sheet(osheet.Name)
    
    If osheet.TitleBlock Is Nothing Or osheet.drawingviews.count=0 Then Exit Sub
 otitleblock=osheet.TitleBlock
 otextboxes=otitleblock.definition.sketch.textboxes
 For Each otextbox In otextboxes
     If otextbox.text= "<ÉCHELLE>" Then
        drawingviewname =ThisApplication.activedocument.ActiveSheet.drawingviews.item(1).Name
        otitleblock.setpromptresulttext(otextbox, ActiveSheet.View(drawingviewname).ScaleString)
    End If
    
Next

Next
ThisApplication.activedocument.sheets.item(1).activate
InventorVb.DocumentUpdate()

 

0 Likes
Reply
Accepted solutions (1)
549 Views
5 Replies
Replies (5)

MechMachineMan
Advisor
Advisor
I would think your 2nd last line accomplishes this.

--------------------------------------
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
0 Likes

srionde
Enthusiast
Enthusiast

Unfortunatly no, when it still the same even without this line

0 Likes

Owner2229
Advisor
Advisor
Accepted solution
For Each Osheet In ThisApplication.activedocument.sheets
  If osheet.TitleBlock Is Nothing Or osheet.drawingviews.count=0 Then Exit Sub
    otitleblock=osheet.TitleBlock
    otextboxes=otitleblock.definition.sketch.textboxes
    For Each otextbox In otextboxes
      If otextbox.text= "<ÉCHELLE>" Then
        drawingviewname =ThisApplication.activedocument.ActiveSheet.drawingviews.item(1).Name
        otitleblock.setpromptresulttext(otextbox, ActiveSheet.View(drawingviewname).ScaleString)
      End If  
    Next
Next
InventorVb.DocumentUpdate()

Hope this will work for you... 

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
0 Likes

srionde
Enthusiast
Enthusiast

Thanks a lot it's working pretty good now !!!

 

However I had a mistake when using the code, at this line :

 

drawingviewname =ThisApplication.activedocument.ActiveSheet.drawin?gviews.item(1).Name

 

So i copy and paste the line from my previous code. which exactly the same as yours and it worked ??!!.

 

 

drawingviewname =ThisApplication.activedocument.ActiveSheet.drawingviews.item(1).Name

 

And i see now writing this email the line I copy and paste from you has a ? on it which is not here on my inventor.

0 Likes

Anonymous
Not applicable

I use the same rule to write 'View Scale'

 

I have a problem when I save the documents.

kép3.JPG

kép4.JPG

 

My rule:

 

For Each osheet In ThisApplication.activedocument.sheets
    ActiveSheet=ThisDrawing.Sheet(osheet.Name)
    
    If oSheet.TitleBlock Is Nothing Or osheet.drawingviews.count=0 Then Exit Sub
    otitleblock=osheet.TitleBlock
    otextboxes=otitleblock.definition.sketch.textboxes
    For Each otextbox In otextboxes
        If otextbox.text="<View Scale>" Then
            drawingviewname=ThisApplication.activedocument.ActiveSheet.drawingviews.item(1).Name
            otitleblock.setpromptresulttext(otextbox, ActiveSheet.View(drawingviewname).ScaleString)
        End If
    Next
Next
ThisApplication.ActiveDocument.Sheets.Item(ActiveSheet).Activate
InventorVb.DocumentUpdate()

 

I would like to ask some help. I can't understand how work this rule.

 

Thank the help.

0 Likes