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 command to republish dwf file...

7 REPLIES 7
Reply
Message 1 of 8
Ion01
485 Views, 7 Replies

Ilogic command to republish dwf file...

I would like to use code to open a dwf markup and then republish the markup. Here is the code for the first step of making the dwf for the next person to check and mark up:


opath = ThisDoc.WorkspacePath()

oname = ThisDoc.FileName(False) ' without extension
DWFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD95-2F4D-42CE-8BE0-8AEA580399E4}")
oDocument = ThisApplication.ActiveDocument
oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
oDataMedium = ThisApplication.TransientObjects.CreateDataMedium

If DWFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then
oOptions.Value("Launch_Viewer") = launchviewer
oOptions.Value("Publish_All_Component_Props") = 1
oOptions.Value("Publish_All_Physical_Props") = 1
oOptions.Value("Password") = 0
End If

'Set the destination file name
oDataMedium.FileName = opath & "\Markups\Check\" & oname & ".dwf"

'Publish document.
Call DWFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)

---------------------------------------------------------------------------------------------------------------------------------------------------

 

Once the dwf has been marked up I have the follwoing simple code to open the dwf as an overlay on the idw:


opath = ThisDoc.WorkspacePath()
oname = ThisDoc.FileName(False)

ThisApplication.Documents.Open(opath & "\Markups\Check\" & oname & ".dwf")

Now I want code to use the  republish all sheets command and dont know how to go about that..... If I run the code I already use it doesn't retain the markups and just publishes a new dwf but I need to retain the markup history and the republish all sheets command does this but I don't know how to call that in Ilogic. Any help would be great! Thanks!

7 REPLIES 7
Message 2 of 8
adam.nagy
in reply to: Ion01

Hi,

 

Unfortunately, I did not find a DWF publish option for republish. I also did not find the ControlDefinition for it and no Command is triggered when you click "Republish Markup Sheets"

So it's not looking good 😞

 

I'll check if perhaps that option was just left out of the help file but actually is implemented in the API.

 

Cheers,



Adam Nagy
Autodesk Platform Services
Message 3 of 8
adam.nagy
in reply to: adam.nagy

Hi,

 

I checked the list of control definitions before opening the drawing :-s

 

My colleague pointed out that the AddIn does provide ControlDefinitions, so you can achieve what you want. 🙂

 

I wrote a blog post about this:

http://adndevblog.typepad.com/manufacturing/2014/10/republish-markup-sheets.html

 

Cheers,



Adam Nagy
Autodesk Platform Services
Message 4 of 8
Ion01
in reply to: adam.nagy

Thanks for the help adam. I have a problem though. I copied your code directly into a new Rule. I make sure I have a markup overlay then run the code and first I got a message saying set is no longer supported so I simply removed the word set. Next I get Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))

 

I don't know what to do to fix it.....I am using inventor pro 2014

Message 5 of 8
adam.nagy
in reply to: Ion01

Updated the blog post with iLogic code.

Hope that works for you.

 

Cheers,



Adam Nagy
Autodesk Platform Services
Message 6 of 8
Ion01
in reply to: adam.nagy

Thanks! That was a huge help! I was able to use the open and close DWF pieces as well so the blog was helpful!

Message 7 of 8
Ion01
in reply to: adam.nagy

Well I thought it was working well and the code does but now it messes with inventor. For instance after running the code it will make every time I hit the open icon it brings in the overlay or if I hit save it makes a dwf.....

 

Here is the code I have:

 

SyntaxEditor Code Snippet

On Error Resume Next

opath = ThisDoc.WorkspacePath()
oname = ThisDoc.FileName(False)

ThisApplication.Documents.Open(opath & "\Markups\Needs Revision\" & oname & ".dwf")




 Dim oCommandMgr As CommandManager
oCommandMgr = ThisApplication.CommandManager

' Get the collection of control definitions
Dim oControlDefs As ControlDefinitions
oControlDefs = oCommandMgr.ControlDefinitions


Call oCommandMgr.PostPrivateEvent(
  PrivateEventTypeEnum.kFileNameEvent,opath & "\Markups\Needs Revision\" & oname & "1.dwf")
Call oControlDefs(
  "MarkupManager:Command: DWF Republish Markup Sheets").Execute


Call oControlDefs(
  "MarkupManager:Command: DWF File Close").Execute
  


System.IO.File.Delete(opath & "\Markups\Needs Revision\" & oname & ".dwf")

ThisDoc.Launch(opath & "\Markups\Needs Revision\")
Message 8 of 8
wayne.brill
in reply to: Ion01

Hi,

 

Here is a suggestion to try:

 

>> >>

Use
oControlDefs("Command Name").Execute2(True)

instead of

oControlDefs("Command Name").Execute

 

That will execute the command synchronously. It will wait for the command to finish before continuing to the next program statement.

<< <<

 

 

Thanks,

Wayne



Wayne Brill
Developer Technical Services
Autodesk Developer Network

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

Post to forums  

Autodesk Design & Make Report