Drawinf file open from assembly and run external rule

Drawinf file open from assembly and run external rule

Anonymous
Not applicable
453 Views
3 Replies
Message 1 of 4

Drawinf file open from assembly and run external rule

Anonymous
Not applicable

Hello all

 

i have problem in the following code, my idea is to open drawing from assembly and update all the sheets (with help of external rule), can anyone please let me know where is the problem in my code

 

thanks

 

v.sureshkumar

 


Dim oCurrentSheet As Sheet
' Iterate through the sheets
Dim oSheet As Sheet
FullFilename = ThisDoc.Path & "\drawings"& "\Panel_assy_LAVT.idw"
Dim oDrawDoc as DrawingDocument = ThisApplication.Documents.Open(Fullfilename)
oDrawDoc.Activate


For Each oSheet In ThisDoc.Document.Sheets

oCurrentSheet = ThisDoc.Document.ActiveSheet
oSheet.Activate
iLogicVb.RunExternalRule("Auto_dim_arrangement")
iLogicVb.RunExternalRule("Update_all_sheet")
iLogicVb.RunExternalRule("Drawing_view_scale")
iLogicVb.UpdateWhenDone = True

oSheet.Update
Next
iLogicVb.RunExternalRule("Zoom_fit_drawing")
'return to original sheet
oCurrentSheet.Activate

MessageBox.Show("All Drawings Updated Successfully", "Panel Selection")

 

 

 

 

 

0 Likes
454 Views
3 Replies
Replies (3)
Message 2 of 4

MechMachineMan
Advisor
Advisor

You need to revisit the logical flow of your programming. You had a lot of things out of place.

 

And your issue was grabbing a new variable instead of using a document that you have already saved.

 

 

Dim oCurrentSheet As Sheet
' Iterate through the sheets
Dim oSheet As Sheet
FullFilename = ThisDoc.Path & "\drawings"& "\Panel_assy_LAVT.idw"
Dim oDrawDoc as DrawingDocument = ThisApplication.Documents.Open(Fullfilename)
oDrawDoc.Activate

oCurrentSheet = oDrawDoc.ActiveSheet
For Each oSheet In oDrawDoc.Sheets
oSheet.Activate iLogicVb.RunExternalRule("Auto_dim_arrangement") iLogicVb.RunExternalRule("Update_all_sheet") iLogicVb.RunExternalRule("Drawing_view_scale") iLogicVb.RunExternalRule("Zoom_fit_drawing") iLogicVb.UpdateWhenDone = True oSheet.Update Next
'return to original sheet oCurrentSheet.Activate MessageBox.Show("All Drawings Updated Successfully", "Panel Selection")

 


--------------------------------------
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
Message 3 of 4

Anonymous
Not applicable

Dear Justin Konecsni 

 

Good day

 

thanks for your reply, since i am new to ilogic and API, i don't  know how to re arrange my code, can you please advice how to re arrange or write code 

 

v.sureshkumar

 

 

 

0 Likes
Message 4 of 4

MechMachineMan
Advisor
Advisor

If you would have compared the 2 blocks of code, you would see the code I posted already was a revised version.............................


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