Drawing View won't update

Drawing View won't update

Anonymous
Not applicable
1,861 Views
6 Replies
Message 1 of 7

Drawing View won't update

Anonymous
Not applicable

Hi all,

 

I've got a macro which is creating .ipt and .idw files from templates. I'm once created I'm replacing the reference in the .idw to refer to the newly created .ipt file. The problem is that the drawing view isn't updating... I've been googling like mad, and i've tried the suggestions I've found, that is make the .ipt file dirty then udpate the drawing, but that hasn't worked. I've tried just using the drawingdocument.update function, but that hasn't worked either... I'm not sure what else I can try... 

 

Any suggestions?

0 Likes
1,862 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable

Still trying to figure this one out guys.

 

Here's what I've tried:

osheet.update  - This doesn't work

odoc.update  - This doesn't work

odoc.update2  - This doesn't work

 

osheet.suppressed = true

osheet.suppressed = false  - this DOES update the view, but not the annotations And it's really slow.

 

Inventor says that osheet.drawingview(1).uptodate = true, but when you select the view in the GUI, the update button is available, when you press the button the view updates correctly.

 

 

 

Any suggestions?

0 Likes
Message 3 of 7

matt_jlt
Collaborator
Collaborator

I'll need more code to be able to understand exactly whats happening so I can try and help you.

0 Likes
Message 4 of 7

Anonymous
Not applicable

There isn't a definite flaw in the code, so unless I'd have to post the entire project so you could replicate the problem, and there's many links to network locations.

 

Perhaps some images will help to explain my problem.

 

Photobucket

 

The above image shows the part (top window) as generated by my add-in. The bottom window shows the drawing of that same part also generated by my add-in. You'll notice that the drawing view does not accurately reflect the part. Instead it shows the part which was used as a template for the creation of the part in the top window.

 

The code below is used to replace the reference to the new created part BEFORE carrying out any other tasks on the drawing (such as re-size the drawing view).

        oTemplate = m_inventorApplication.Documents.Open(sTemplateFileName, False) 'Open the template drawing file
        oTemplate.ReferencedDocumentDescriptors.Item(1).ReferencedFileDescriptor.ReplaceReference(sNewFilePath & PartName & ".ipt") 'Replace the reference of the template part file, with the created part file.

        oTemplate.ReferencedDocuments.Item(1).Save() 'Save the created part file
        oTemplate.SaveAs(sNewFilePath & PartName & sNewFileExtension, True) 'Save the drawing file to match the created parts filename.

 

You'll notice in the image above, that the drawing view is selected, and the 'Update' button in the quick access toolbar is enabled, suggesting that the drawing view is not up to date.

 

 

The image below shows the result of what happens when you press that 'Update' button. Clearly the drawing view now correctly reflects the part shown in the top window, however the scale needs to be adjusted.

Photobucket

 

 

SO... My question is, How do I invoke that Update command from the API? I've tried the update methods of the sheet, and document objects, but they don't work. The Rebuild method is not available to drawing documents.

 

Any assistance would be great!

 

NOTE: I've attached both of those images because they're squashed in this window.

0 Likes
Message 5 of 7

matt_jlt
Collaborator
Collaborator

Just a hunch, do you have this problem if you open your template with visibility turned on?

e.g.

oTemplate = m_inventorApplication.Documents.Open(sTemplateFileName, True)

 

I've had a few problems in the past with updating when i've opened a file in the background.

 

also try saving a copy of the IDW before you replace the reference (basically just changing the order of processes)

0 Likes
Message 6 of 7

Anonymous
Not applicable

Excellent! Setting the open behaviour to visible = True seems to have done the trick...

 

Thanks for the suggestion!

0 Likes
Message 7 of 7

matt_jlt
Collaborator
Collaborator

No problems, If you want to avoid seeing what is happening on the screen you could try disabling screen updating temporarily then once your addin has finished enable screen updating. It shouldn't give you any updating issues.

 

ThisApplication.ScreenUpdating = False

 

Regards, Matt.

 

If your problem is solved, don't forget to press the Accept Solution button
.

0 Likes