Copying views into another sheet (iLogic or API )

Copying views into another sheet (iLogic or API )

ulasdeniz
Mentor Mentor
2,317 Views
4 Replies
Message 1 of 5

Copying views into another sheet (iLogic or API )

ulasdeniz
Mentor
Mentor

Suppoese I have series of catalogue drawings of AssemblyA.dwg and AssemblyB. dwg  that are completed. (Each set contains a lot of version.)

 

And I need to create an Assembly drawings called AssemblyA-B.dwg    which contains AssemblyA.dwg and AssemblyB. dwg as subassemblies. I need to create an automatik task to create the all of combination of the AssemblyA-B.dwgs without manually copying and pasting the views. The code will place  (or change in prepared template  ) the views of the AssemblyA.dwg and AssemblyB. dwg into AssemblyA-B.dwg  

 

Do you have a solution for ilogic or API? (I logic preferred)


Ulaş Deniz


Forumlarımızda çözülen sorularınızı "ÇÖZÜM OLARAK KABUL ET" ( "ACCEPT AS SOLUTION" ) seçimiyle işaretlemeyi lütfen unutmayın.
Beğendiğiniz mesajları lütfen "Övgü Puanı" (KUDO) ile ödüllendirin.
Youtube : https://www.youtube.com/channel/UCkJpVueGScmJvW1RIgqttSg

0 Likes
Accepted solutions (1)
2,318 Views
4 Replies
Replies (4)
Message 2 of 5

Balaji_Ram
Alumni
Alumni
Accepted solution

Hi Ulas,

 

Here is an iLogic code to copy view from one sheet to a sheet in another drawing.

You may need to tweak the view index and the file path to suit your needs.

 

Dim oSrcDwg As DrawingDocument
oSrcDwg = ThisApplication.ActiveDocument

Dim oDestDwg As DrawingDocument
oDestDwg = ThisApplication.Documents.Open("D:\Temp\Inventor\MyProj\Axle\Test.dwg")
    
Dim oView As DrawingView
If oSrcDwg.ActiveSheet.DrawingViews.Count < 1 Then
    MsgBox ("No views found in the source drawing !")
    Return
End If

oView = oSrcDwg.ActiveSheet.DrawingViews(1)

Dim oSheet As Sheet
For Each oSheet In oDestDwg.Sheets
    oSheet.Activate
    Call oView.CopyTo(oSheet)
    Exit For
Next

Call oDestDwg.Save
Call oDestDwg.Close(False)

Regards,

Balaji



Balaji
Developer Technical Services
Autodesk Developer Network

Message 3 of 5

Jef_E
Collaborator
Collaborator

@Balaji_Ram Thanks for this example, but I would like to go a step further. How should can we handle multiple views that depend on each other?

 

Example:

 

oSrcDwg.ActiveSheet.DrawingViews(1) = base view

oSrcDwg.ActiveSheet.DrawingViews(2) = Section from base view

 

I would like to copy the section + the base view to my new dwg. How should I handle this?



Please kudo if this post was helpfull
Please accept as solution if your problem was solved

Inventor 2014 SP2
Message 4 of 5

MechMachineMan
Advisor
Advisor
Either select your base view first or use command manager

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

DRoam
Mentor
Mentor

@Jef_E wrote:

@Balaji_Ram Thanks for this example, but I would like to go a step further. How should can we handle multiple views that depend on each other?


 

I would like to be able to do this, too. The copy/paste via Command Manager isn't a good solution. It's not pure-API, it's clunky, and it results in duplicates of the Views (with new Labels) rather than moving the Views themselves.

 

So I created an idea for this here: iLogic/API: Move or Copy multiple Drawing Views to different sheet at once.

 

Please consider giving it a vote.

0 Likes