AutoCAD Inventor :: API - How To Release Document Object Correctly
Mar 27, 2012
I have made a VB.Net Add-In for Inventor 2011, in a few functions it opens one or more files or sets a reference to already opened files. The release of the resource to this documents seems to be the problem.
In PDM (Productstream Pro) we want to change document states and there for the documents have to be closed in Inventor. When using some Add-In functions prior to the state change in PDM, we get a message from PDM that Inventor still has the files open but inventor does not show any open files (of course we can not see files that were opened in the background).
Only manual operation to solve this is to close inventor or open the drawing and the part used on the drawing and close them top down (drawing first, then part).
I'm stuck with open files that don't seem to be open.I think this is because the add-in sets a reference to the part used on the drawing and then changes something in the drawing.How do I release the resources correctly?
I've created a Inventor 2011 Add-In using VB.Net with VS2008.
This add-in does all kinds of things, but it will not release some documents.
Well I don't know that for shure but it looks like that.
We use Productstream Pro and when changing state of a document it says the document is in use while there are no documents visibly open in Inventor. This only occures when I use my add-in.
Exact steps: Load drawing document from PSPPerform action with add-in which gets a custom iProperty from the Part file used on the Drawing and fills the display name of the Drawing with itSave the drawingClose the drawingIn PSP try to change state of the part file used on the drawingGet message from PSP stating the part is in use
In my code I've tried some things to prevent this behavior but non of them work.
I've tried: Setting unused objects to "= Nothing"Releasing objects using "Marshal.ReleaseComObject(obj)"Calling "m_inventorApplication.CloseAllUnreferencedDocs()" and "System.GC.Collect()" on the "m_appEvents_OnTerminateDocument" event.
When I close a large document Photoshop does not release the memory. If I open another document the program is slow and not resposive. If I close out of Photoshop and restart it then load the other document it is quick and responsive again.
My goal is to be able to store any object type (mainly an image jpg/bmp) inside a part that is not accessable through the normal user interface to be used with my addin.
I have been searching around and it seems like GetPrivateStream is the way to go.
Any working example of GetPrivateStream in vb.net and confirm if it actually stores the data inside the part.
I can't find a solution anywhere or any decent referencing material for this. If there is a better method of achieving this?
Just started using autocad 2013 this weekend and was able to create a document and draw some rectangles with specific dimensions for a project I'm working on. The idea is to print it out and cut the rectangles out on a piece of foam board.
So I printed it out but all of the rectangles are crazy small. Like 50% smaller. I checked the objects and they're all showing as being the right size. Then I realized the background grid is the 8.5 x 11 landscape paper and that my rectangles were to scale of the printout but not 1:1 of the dimensions that I entered and the objects said they are.
This code works with no errors but does not change the text size. A user can over ride the text size (Font size) so I'm hoping it is possible thru code.
Dim oSketch As Inventor.Sketch Set oSketch = oPartDoc.ComponentDefinition.Sketches("Sketch1") Dim oText As Inventor.TextBox Set oText = oSketch.TextBoxes.AddByRectangle(pnt1, pnt2) oText.Style.FontSize = 0.1
I have two identical computers (dell 745's) running windows 7 and Autocad 2012 (64bit). on one machine opening a drawing which has is a linked OLE document everything displays properly. On the other machine the same drawing is opened and only the top 1/4 or so of the OLE document is displayed in the area allocated to the OLE.
This drawing also displays correctly on a HP laptop running win 7 and autcad2012.
I have dumped the variables from all three machines using setvar and copy and pasting and can see nothing that is different between the machines.
I've used this method a lot in the past using acad2008/win xp pro and did run into a file occasionally the would mess with the OLE but it's been limited to one file once in a while. Now since I've upgraded this one machine refuses to handle any OLE's. I like the editing commands in word better the the limited commands in AutoCAD tables or Exel for that matter.
I am trying to write a script that will automatically hatch several drawings. The drawings contain an area in which there are several objects that need to be hatched. For each drawing the objects vary in location within the one area.I figured I would set up my script to encompass the area with the object select hatch technique. This works fine if the objects in the area have no Islands. However when an object within the "object select hatch area" contains Islands it shades the whole object ignoring the Island or if it does recognize an island it will create an individual hatch for it.
However when I use the pick internal point method the hatch comes out as expected for the object with the Islands in it.
One of the objects in my scene is not rendering correctly. It is a side panel grating with holes in it. In the viewport it looks fine, but once I render it only some of the holes display. I created the front grating with the same method and it renders every hole just fine.
using System; using System.Threading; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using System.Runtime.InteropServices; using Autodesk.AutoCAD.Interop.Common; using Autodesk.AutoCAD.Interop; using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.DatabaseServices; using Autodesk.AutoCAD.Runtime; using Autodesk.AutoCAD.EditorInput;
[code]....
Working Environment:-
Visual Studio 2010AutoCAD 2011 C#
After run following error will occure
"An unhandled exception of type 'System.TypeLoadException' occurred in mscorlib.dll
Additional information: Method 'CopyTo' in type 'Autodesk.AutoCAD.ApplicationServices.DocumentCollection'
from assembly 'acmgd, Version=18.1.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation ."
When I use select object, it never displays the marquee correctly. One of two things will happen.
It will
1. Not even display the marquee at all e.g. I use select object by rectangular selection and the rectangle marquee box is invisible (although I can still select things)
or
2. If the marquee does display it shows it behind the objects, instead of in front of them, as scene in the image below.
I want to insert a word document with several pages in autocad by the OLE OBJECT function. The problem is the insert only the first page. How to follow the other pages?
I created a closed object that had a Bezier curve as part of it's definition. I wanted to scale it by 110% and then use this second enlarged object to create a sort of a background underneath the first object to create a sort of a shadow effect. But rather than the second object being uniformly larger than the first it intersects the original object in ways that don't make sense to me.
Is there an easier/differnt way to create an effect like this? I can do it but have to manually adjust a lot of points in the new object so that they create a uniformly larger version of the original object but it's a lot of effort for something that works fine for normal polygons with straight lines (e.g. a star with 5 points).
i've attached an image of what I get with this technique of creating two examples of two objects one a 110% scale version of the other. The first star shows the effect I'm trying to get and the second shows the problem (the red border does not surround the black object uniformly around the perimeter)
If I load a dll file into the autocad (using NETLOUD), and after a while I want to make some changes in the dll, then re-build it. In order to do so, I must close the autocad, otherwise I'll get an error ("Unable to copy file,,, because it is being used by another process..."). There is anyway to release the dll so I can change it without closing the autocad everytime?
When I plot or run print of a drawing the view port frame is in the display and prints out with the drawing. How do I release this frame from display so it will not print?
I am trying to cut sections using Inventor I will begin by saying I am a fairly new user. On numerous occasions I am running into an issue where the section cuts are not shown correctly? I have attached an image showing an example of what I am talking about, you can clearly see that there are bolts and plates that should be displayed in the section cut which is shown above.
I am working on a sheet metal tee and i am having a problem with the Rip feature on this particular piece. I am not understanding why it will not rip all the way through this part.
I have an IPN exploded assembly in an idw file. The individual parts were created in a multibody solid and sent out to and assembly using the "make components" command. My normal way of working is to leave the source part with appearance sent to "default". One the bodies are sent out to individual parts i manipulate material and appearance in the individual IPT files.
This is the problem..
The IPN file looks fine with the correct appearances when i open the IPN file. However, the iso view to the IPN in the IDW file does not shade correctly. It appears to shade all parts in the original gray "default" appearance.
The idw with the linked files are about 7MB after packngo and zip. Attach won't work. Please provide alternate means to transmit file. In the mean time the best i can do is screenshots
I am using a form to make the changes in the assembly, but when I change body styles ( 1 piece to 2 piece) it is not updating correctly unless I regen the rule. It is having trouble with the 2nd body piece. It doesn't want to change it unles I do a regen.
I have found a couple of times now a problem with Parameters not updating correctly. Last Tuesday (26/06/2012) I logged a call with the VAR and they are yet to contact me about the problem. In the past when I found the same thing, a different VAR made excuses about not using the most current software as I developed the model on IV2010. The Parametric model made use of VBA and Skeletal modelling and the VAR made excuses along the lines of we weren't running the most current software, didn't make use of iLogic and since I was using VBA and did not pay for the code checking service the problem for them disappeared as they were going to do no more. When we finally upgraded to IV2012 and the problem still existed they consequently chose the excuse of my VBA code being the problem, consequently I then created a simple rule in iLogic and demonstrated the problem that way.
To summarize, the model is a Parametric Skeletal assembly, it utilizes VBA for a user interface. The problem existed in IV2010, IV2011, IV2012 and IV2013. There are pictures attached to show the problem.
When I draw an object in Illustrator, the shape appears filled in the view of the document, even though it is set to no fill in the apprearance panel. The thumbnail for the object in the layers panel shows it with no fill, and if I copy it and paste it into Photoshop it has no fill there, so it really has no fill. Just in the view of the document where I am drawing it appears with a colored fill.
I'm drawing lots of overlapping shapes, I want them with no fill so I can see the ones behind. This is happening with all the tools I have tried: pen, pencil, paintbrush, shapes, whatever. I've tried restarting Illustrator, also restarting my computer, nothing changes. I may have clicked on some setting inadvertently somewhere, as I've been exploring and clicking on lots of things to see what they do.
The goal is to copy a text object from one illustrator(CS6) document to another maintaining live type and having a graphic style applied from the appearance panel. When an effect like an arch is applied it is converting the text to outlines during the copy and paste, however a straight fill will not. The type of font (TrueType, OpenType, Postscript) does not seem to affect the problem.
Alternatively I have been able to take the desired appearance, create a graphic style from it, apply that to a path and transfer the graphic style to the new document via copy/paste, then apply it to live type on the new document. Obviously this is not ideal.
I learned Autocad on release 12 and then migrated to r14 and 2001. Nowadays most drafting is done with r14. However I want to be able to insert a .jpg into the drawing
environment and draw lines over it. Specifically, I want to take pictures of Christopher Dressers designs and bring them into Autocad and then trace over them. I feel I will get a huge education into architectural ornament as well as becoming more facile with lines.
I haven't kept up with Autocad's upgrades but undoubtedly the later releases have this functionality. Which one will work?
we have DWG files with multi leader lines, we would like to save these files to an earlier release so that others could access, what would be the earliest date recommended.
I´m having a couple of problems with getting data correctly from an Excel Sheet. I´m using the Excel Sheet to get Data for the Stock Number based on geometry.
First time the Excel File get´s opened it always cannot find the first sheet. I´m using a german Version and Sheet1 is Tabelle1 in german.
It always searches for sheet1 the first time the script runs on a new derived assembly. The second time (on second part) it correctly finds Tabelle1 and reads the correct value.Here is the code I´m using:
And there is another issue which I have solved already but still gives me a bit of a headache. When the userdefined property IdentNr gets written into the part it always defaults to a numerical value, which means that I always get a comma at the end of the Stock Number.
Only when I define IdentNr like this:
Dim IdentNr As String
the format is correctly set to Text.I expected that when you read a value from an Excel Cell that the Format of the Cell gives the format of the user defined property. Is that not correct?
It doesn't happen very often (apparently, 8 days ago was the last time), but I would like to know more about this error.
The .png I've attached shows what happens more easily than I can describe it.
It only happens on Part1 (and possible Assembly1?). If I've made a new part and the menu loaded correctly, it won't load improperly on a later new part (, like Part2, Part 3, etc). It does not happen saved parts that I open. If I have other files open when this happens, the Manage menu seems to be correct in any file, but Part1. Closing IV and reopening has fixed it every time, but one. The time closing/reopening IV didn't fix it, I closed it again, and reloding IV again, the menu was fine.
The visible portions of the buttons work correctly, but the empty spaces where the icons for the button should appear, do nothing.