AutoCAD .NET :: Adding Entity On New Drawing (document) With New Layer
Nov 29, 2012
I am trying to add an entity on a new drawing (document) with a new layer.
Following is the code snippet I have right now.
[CommandMethod("TEST")] public void Test() { Document newDoc = Application.DocumentManager.Add("acad"); Database db = newDoc.Database; DocumentLock docLock = newDoc.LockDocument(); try { using (Transaction tr = db.TransactionManager.StartTransaction()) { BlockTable bt = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as [code]..........
PTPUtils.CreateLayer() method creates a new layer in the given DB. However, the code gives me an "eKeyNotFound" exception in the line p.Layer = newLayer.
If I remove the p.Layer line, the code works very well. But the entity only goes to the default layer "0".
I'm trying to add an attribute to an entity, however it seems that the AttributeDefinition requires a Point3d and as such appear in my modelspace. I don't want this, i just wanted it to appear as an attribute with a value when i click on my entity, is there any way of making it so that i does not add into modelspace?
BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForRead);for (int i = 0; i < prSelectionResult.Value.Count; i++){ // Get the entity the user had selectedEntity ent = (Entity)trans.GetObject(prSelectionResult.Value[i].ObjectId, OpenMode.ForWrite);if (ent.GetType() == typeof(BlockReference)) { // Add attribute to layerBlockReference blockRef = (BlockReference)ent;. [code]...
We are civil engineering company, and most of out work is to get drawing from a civil architects and add our layer on that drawing, but when opening those drawing we get the message that there is ObjectARX missing, and from that point on our life become very difficult, we cannot copy paste objects, and lots of other basic action cannot be complete without crashing autocad.
I am using AutoCAD 2010, but i saw it happening with all the versions of AutoCAD.search for enablers are set on in Option.
The code below crashes with an "attempt to write to protected memory" in debug mode (it crashes when it hits acDocMgr.add)but in the Release version it works fine. I am using Command Flags.Session
Dim acDocMgr As DocumentCollection = Application.DocumentManager Dim pStyle As Integer = Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("PSTYLEMODE") Dim acDoc As Document = Nothing If pStyle = 1 Then acDoc = acDocMgr.Add("acad.dwt") Else acDoc = acDocMgr.Add("acad -Named Plot Styles.dwt") End If
how to make a layer or an entity transparent within a viewport?
I figured out the following code found in:
[URL]
It gives an error at New Autodesk.AutoCAD.Colors.Transparency(127)
Using transactie AsTransaction = DWG.TransactionManager.StartTransaction Dim Layertable AsLayerTable = DWG.LayerTableId.GetObject(OpenMode.ForRead) Dim VP AsViewport = transactie.GetObject(Doc.Editor.CurrentViewportObjectId, OpenMode.ForWrite) Dim LVPO AsLayerViewportProperties ForEach LayerID In Layertable
I want to add a vector image(.ai file) to my photoshop document, how would I do that?
Currently I export the vector image as png, then i import the png to PS, but it is a raster image, I would like for it to be vector, like a custom shape...
Pic 1. I have an image I want to use as a background, however the image is not complete. I need a part of pic 2 to fullfill it.
Pic 2. The colors around the object doesn't match the colors of Pic 1.
Normally it would be best to cut the object out. However in this case it wouldn't look nice (the object is mixed out (in color) with the rest of the image). If I cut out something the object won't look "proper".
My question:
How can I blend pic 2 on pic 1, using the original object from pic 2 (as it is), and at the same time blend the colors around it, so that it matches that of pic 1 / or simply remove it somehow?
I have 300 photos that are being saved as thumbnails for my online store. I am looking to see if I am able (in automated batch saving) to add "-TN" after the document name, before the extension. It will let me add the dash but not "TN."
An example of how my document name needs to be is "MyFile-TN.gif".
I am trying to add page numbers to an existing document. I have tried to add them in Prepress, but all I see is the "Print File Information" and even that is not in a location I want. I have the "Position Within Page" checked.
My document palette adds the same colors that are NEVER in my art every time. I swear it's a glitch. The colors are so bizzare. And when I go to delete any of them, it says I can't because they are in use. But they are for sure not being used.
Here's a list of the colors:
Black A0QM, Pantone 142, Black A0QM (1), Black A0QM (2), Black A0QM (3), DIC 2287p* (1), PANTONE 142 (1), Black A0QM (4), PANTONE 142 (2), Black A0QM (5), Black A0QM (6), Black A0QM (7), DIC 2287p* (1) (1), PANTONE 142 (3)
That's the order they are always in. I don't even know where you would get any of those colors and what they would be used for? Except the Pantone of course.
Is there event for change current (active) layer of document?
(it's not Database.ObjectModified - it's not raised).
I tried to do it with binding as:
public void Initialize() { var layerList = Application.UIBindings.Collections.Layers; layerList.PropertyChanged += new PropertyChangedEventHandler(LayerList_PropertyChanged);
And -= in Terminate, but... Autocad 2012 chashed _sometimes_!!!
Impossible to understand when it happened. So I reject this way. Is there other way to handle this event?
I have a drawing of a floor plan, and on a separate drawing I have text that I need to add to the floor plan drawing.
I've used the XREF command and positioned it exactly where it needs to go, but I can't edit the text drawing unless I "Open XREF in place"
I got close by going to the XREF dialog and "Binding.." the drawing as an INSERT and now it's one huge block.
I'm trying to insert the drawing with the text on the drawing with the floor plan so it's one drawing and so I can edit the text or move things around if I need to.
Im looking to make a simple ilogic rule that can toggle an option in the document settings, the setting I would like to change is the Document settings> Modeling> Participate in assembly and drawing sections
I would like a form to switch the option on and off quickly, its a really usefull function however I know a few of my colleagues wont use if they cant find it easly.
After looking thru the api, i'm finding it hard to get a list of orphaned dimensions.
I can get a list of all the dimensions...easy.
I've basically deleted a part from the assembly and now want to remove that dimension in a section view on the drawing document.
But looking / comparing the properties of a non-orphaned vs an orphaned shows nothing.
Is there an orphaned list?
Is there a color override switch somewhere?
Or can I somehow get the object that the dimension is trying to reference and check to see if it is valid or has a valid file reference...or something?
I am trying to create a new base view in drawing-document.
I can get hold of the view but cant find a way to set reference data --- would like to set the "Line Style" to "As Parts" and "Hidden Line Calculation" to "All Bodies".
Is it possible to add materials to a 2D drawing? I'm working on a floor plan and would like to add flooring materials to it but not sure how or if this is possible?
From a VB.Net program, I'm trying to create a dimension on a drawing document between two parts in an assembly. I can get the parts using component occurrence. The line marked below throws the following error: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG)).
As you may see, I have allocated memory for both "Edge" and "Face" (Dim oEdge1 As Face) albeit one is commented out. Attached is the screen shots from the attribute helper add-in. In it, you will notice that the attributes are of type: "Face".
Public Sub CreateDrawingDimension(ByVal Part1 As String, ByVal Part2 As String, ByVal AttName1 As String, ByVal AttName2 As String) ' Get the Active Drawing document Dim oDrawDoc As Inventor.DrawingDocument oDrawDoc = invApp.ActiveDocument [code]........