I wrote code for an application that stores links to lines and blocks in dictionaries using handles. The routines work well and I can manipulate the data marvelously, but if one of the lines or blocks get erased the whole danged opera falls apart. I knew this when I wrote the routines and have always been careful about using the ERASE command, as a matter of fact, I considered disabling it.
I am trying to make the package more robust. I have been experimenting with attaching a reactor (:vlr-erased) to the objects which fires when the object is erased. Unfortunately it fires before I can retrieve the handle of the object so that I can remove the references from the dictionaries. The only thing that I can retrieve once ERASE fires is the ObjectID. I can't seem to find a Visual Lisp routine to convert this value to a handle, does one exist? Is there an ObjectID collection that has any references in it?
I can store some ObjectId from my drawing to text file. After that how we can get back ObjectId from string read from that text file. Or have a diferrent way to store the ObjectID.
I have a list of blocks in a datagrid. When i double click a certain record it gets the objectid or handle.
Now i know how too highlight the object. But i don't want to highlight the entity but select it so i can change it's property's in the property pallet.
In the first screen shot you see the code i have. wicht highligts the record but the propperty pallet display no object selected.
But i want it to work like the next picture.
So the question is. When i know an entity's objectid or handle how do i select that entity programticly.
I have a drawing with a Polyline filled with Hatch. Also I have that Polyline ObjectId. So using this ployline ObjectId I want to erase the Hatch inside polyline. How I can erase the Hatch.
I need to use the Handle of the cloned object during a DeepClone override but AutoCAD shuts down when I try to use it.
This is the best I can think of but it still boots me out when I try.
Public Overrides Function DeepClone(ByVal dbObject As DBObject, ByVal ownerObject As DBObject, ByVal idMap As IdMapping, ByVal isPrimary As Boolean) As DBObject Try Return MyBase.DeepClone(dbObject, ownerObject, idMap, isPrimary) Catch Finally CompileCloneObjects(dbObject.Handle.ToString, MyBase.DeepClone(dbObject, ownerObject, idMap, isPrimary).Handle.ToString) End Try End Function
I create a polyline ,and then add it's objectId to a ObjectIdCollection defined by me.After the polyline is created,I would like to obtain it's second and sixth vertexes via this polyline's objectId.
I have stored within an external database a handle of an entity within a drawing. If I have that drawing open and I retrieve that handle and then get the ObjectID from that Handle how do I convert that to a BlockReference so that I can then get position and attrribute values. I can get the position and attributes if I can just get the blockreference from the Object ID.
I am using the following code to get the ObjectID from the Handle:
Public Function ObjectIdFromHandle(db As Database, strHandle As String) As ObjectId Dim nHandle As Int32 = Int32.Parse(strHandle, Globalization.NumberStyles.AllowHexSpecifier) Dim handle As New Handle(nHandle) Dim ids(0) As ObjectId Try ids(0) = db.GetObjectId(False, handle, 0) Catch ex As Exception MsgBox(ex.Message.ToString, MsgBoxStyle.Exclamation, "Error in ObjectIDfromHandle") End Try Return ids(0) 'Return db.GetObjectId(False, handle, 0) End Function
I then want to use this ObjectID to get the BlockReference.
I need to make my application compatible with 2008 and have one error saying that ObjectClass is not a member of SubEntId (As ObjectID) in my InsertBlock routine.
Public Sub InsertBlock(ByVal blockname As String, ByVal trans As Transaction) Dim db As Database = Application.DocumentManager.MdiActiveDocument.Database ' Test if block exists in the block table Dim bt As BlockTable =
If I have a list of handles for Autocad Entities, how would I go about selecting these entities on screen so that the user could add to this selection or remove objects from the selection? I could go with object ids as well if needed.
I have been searching and searching and coming up empty handed or at least coming up with information that doesn't seem to do what I want.
I need to export points from 3D map as a .shp file so I can bring them into Maya and have them line up exactly where they need to be based on their coordinates. The points line up pretty close to right in map 3d, and they have a style assigned to them. When I go to the Map --> Tools --> Export, I choose .shp as the file output, and go through and select the layer I need to export. When I've got everything set up, I get an error message saying "no entity to export." I have searched on the internet for this error but not a lot comes up. I'm not sure what I'm missing in order to make the points export.
Simple example, when overrule Line entity to draw three entities Line, Text, Circle when selecting overruled Line is it possible to identify what object have been selected (in this example it could be Line, Text, Circle).
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]...
I have a method DrawMLeaderLine(Database db, Transaction tr, Point3d point, string text) that draws me a MLeader line to the given point with the given text as annotation. The MLeader line points to the midpoint of a Line entity. What I need is a binding between the Line midpoint and the MLeader line, so when I move or resize the Line, the MLeader line should follow! I already tried to solve that, using constraints, but it doesn't work for Leaders.
This is my code...
public static MLeader DrawMLeaderLine(Database db, Transaction tr, Point3d point, string text) { Point3d mTextLocation = point + new Vector3d(5, 5, 0); BlockTableRecord btr = tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite) as BlockTableRecord; MText mText = new MText(); mText.SetDatabaseDefaults(); mText.SetContentsRtf(text); [code]........
will be called from a different class...
Line line = DrawingUtil.DrawLine(doc.Database, tr, closestPoints.Item1, closestPoints.Item2); //Get midpoint of line double midPointX = (line.EndPoint.X + line.StartPoint.X) / 2.0d; double midPointY = (line.EndPoint.Y + line.StartPoint.Y) / 2.0d; Point3d midPointOfLine = new Point3d(midPointX, midPointY, 0); //Draw the leaderline MLeader leaderLine = DrawingUtil.DrawMLeaderLine(doc.Database, tr, midPointOfLine, "Connection");
Can you add an attribute to a non-blocked entity? Basically, I want to "name" plines.
In case I'm going about this wrong, let me ask the question another way. I'm just getting used to the wonders of attributes & data extraction (I love it!). Right now I have blocks with attributes that I use data extraction to count. I also need some way to calculate length. These blocks represent electrical devices - then I need to calculate the amount of wire used to connect the devices.
So now I use a pline to join the devices, get the length of that polyline, and then manually enter that length into the spreadsheet from the data extraction. But...I'm thinking if I can link an attribute to a pline, then I can include that in the data extraction and automate it. But I don't see how I can use a block for this, since the pline will be completely variable and needs to be "custom-fit" for each circuit.
is there any way to check the entity selected by NonInteractivePickPoint? iwant to get the ownerid if the item selected is a 3d or 2d vertex. How is it written in vb.net?
I have a client that just started using C3D 2010. When I sent him a topographic survey with contour lines (I am also using C3D 2010) he called me and asked if there was a way to select an individual contour line and have it display the elevation in the 'properties' dialog box. I have not been able to find an answer for him.
For AutoCAD 2006, I have an entity that I am changing properties of, but I cannot figure out how to set the colormethod to "By Layer." I am sure that I am missing something, but I am at my wit's end.
I'm borrowing from the samples library in the Inventor:
Public Sub GetSingleSelection()
' Get a feature selection from the user Dim oObject As Object Set oObject = ThisApplication.CommandManager.Pick(kPartFeatureFilter, "Pick a feature") MsgBox "Picked: " & oObject.Name
End Sub
Works fine, and is fairly simple, but the problem I'm having is if I press the escape key after starting the command, but before making my selection, I'm not able to start the command again.
I realize from my searching that using the Selection (Simple) sample allows for an interrupt, with some modification, was just wondering if there was something similar for this simpler selection option.