AutoCAD .NET :: Slowing Down When Changing Block Reference Property Values
Sep 30, 2013
I'm inserting automatically many references to a couple of dynamic blocks in an AutoCAD drawing using VB.NET. If the number of inserted references is not very big, it works fine but, if I´m inserting hundreds of them, I noticed the app is slowing down a lot.
After taking some measures of the time the app uses in its execution, I noticed changing the value of the block reference property is slower as the number of inserted block increases: it takes 10 or 20 miliseconds at the begining but it can take more than 1 second after inserting one thousand of block references (to the same block).This is the function I use to change the property values:
Protected Sub CambiarPropiedades(ByRef ed As Editor, _ ByRef br As BlockReference, _ByVal nombrePropiedad As String, _ ByVal valor As Double) Dim pc As DynamicBlockReferencePropertyCollection = br.DynamicBlockReferencePropertyCollection If br IsNot Nothing And br.IsDynamicBlock Then For Each prop As DynamicBlockReferenceProperty In pc If prop.PropertyName = nombrePropiedad Then prop.Value = valor '
This line takes a long time the first time I call this function for the ' same block reference but it is faster in the next calls . It also changes the block reference name (br.name) in the first call
Exit For End If Next End If End Sub.
Which I call to change all the properties I need to change in an inserted block reference:
CambiarPropiedades(ed, br, "h_testua", objElementoLaboratorio.POS_TEXTO) CambiarPropiedades(ed, br, "d_texto_hor", posxTexto) CambiarPropiedades(ed, br, "largo", objElementoLaboratorio.LARGO) CambiarPropiedades(ed, br, "fondo", objElementoLaboratorio.FONDO)
A weird thing I noticed is that when I call this function to change the first property of an inserted block, it also changes the .Name of the block reference.
Even if I change the order in the property modification, it takes always a lot in the first call, it does not depend on the property I´m changing.
In most cases this works well. However I found a case that it not work as well. When I try to change the definition from a new block that I have created in my test DWG, it disappears from the model.
I have been trying to find a method to extract custom properties from the custom property bag.
I have been able to extract the property value, using the "GetProperty" and the associated "GetValue" method, this method works when I know exactly what property name I am looking for. What do you do when you don't know the property name?
here is my code snippet..
dim myProps as acsmcustompropertybag = mysheet.getcustompropertybag dim myProp as iacsmcustompropertyvalue = myprops.getproperty("SOMENAME") dim myPV as string = myProp.GetValue
what I want to do is:
dim myProps as acsmcustompropertybag = mysheet.getcustompropertybag dim myPN as string = ??????????.tostring dim myProp as iacsmcustompropertyvalue = myprops.getproperty(myPN) dim myPV as string = myProp.GetValue
Having problems using custom pipe properties in pipe label expressions in 2013? I have some expressions relating to stub callouts and the ones that directly reference the custom properties lose that reference every so often.
For example I have and expression called "STUB-Riser-Length2d" which is defined as "{Riser Length} / SQRT(2)" where "Riser Length" is the custom pipe property. Every week or so it changes to "/ SQRT(2)".
I haven't been able to find the pattern as to exactly when this happens yet. All expressions not referencing custom properties seem to be holding steady. The pipe catalog is on a shared drive on the network, if that makes any difference.
Civil 3D 2013 - Windows 7 Pro 64 - Dell T3500 - Xeon 2.67 - 24gb - Quadro 600
I need to match few attribute values from one block to different block. I download a lisp file called; ca.lsp which can match the single attribute value. I modified it for more than one attribute value matching. It is ok but still wish to overcome two issues for batch prcess
1. picking up the blocks by selection
2. click the alternative block numbers of times to match the numbers of attribute values I needed.
How to modify this lisp I can run it by block name selections instead of picking selection which enable me to run batch process for numbers of drawing? That will be good...
Lisp & Demo file attached (Match attribute value, A, B & C to Attribute 1, 2 & 3).
I have a block: “Block_A”. I am trying to determine if a block reference of the block exist.
Currently I would iterate every block Reference in the Block Table, and then dig deep into each block ref . . . . .
I was wondering if I could just take “Block_A” and see if it has reference and where the references are. Perhaps this is just wishful thinking but I was hoping for a faster way to obtain the references then to iterate thousands of blocks in each table record.
Drawing contains a block with "BlkName". I want to insert blockreferences of this existing block using .Net. All shows how to insert a new block and then use the BlockID returned by the insert function. In my case I only have the block name and there is no Block id. How to get it or how to create a block reference of an existing block?
I have a block which contains visible and invisible objects and attributes. I need to export custom block properties, which I added to a dynamic block, like in express tool export attribute information.
or it is possible to convert my custom property, which can contains invisible and visible objects, to attribute value.
s3 = New DimStyleTableRecords3.CopyFrom(vz)s3.Name = nazovtst.Add(s3)_trans.AddNewlyCreatedDBObject(s3, True) _trans.Commit()
Then, in another part of the code, I open the new style and change a property:
Using trans As Transaction = db.TransactionManager.StartTransaction ds = trans.GetObject(ds.ObjectId, OpenMode.ForWrite) ds.Dimtxsty = s2TextStyle.ObjectId trans.Commit() End Using
this works OK for the first time, but when I run the code again, I don't create the new style, I just take the existing one and changing the Dimtxtsty property to the value it already has causes AutoCAD crash
I am trying to get an "idw" or "dwg" title blocks "DESCRIPTION" property using an Inventor macro.
For example, if the description property on a part (ipt) file is "SIDE PLATE", how can I can the same result if the file extension is a "idw" or a "dwg"?
I am having some troubles whit my dynamic blocks. Whenever I add a block property table the window that should be opent doesn't open. The strange thing is that I think it actualy is open but i just don't see it on my screen. The same thing gous for the screen that allows you to ad a parameter to a lookup set. by folowing this link you can see what i mean, it gets interesting after 30 seconds.
[URL]
Is there a variable that decides where on your screen you see these screens?
Whenever I add a block property table the window that should be opent doesn't open. The strange thing is that I think it actualy is open but i just don't see it on my screen. The same thing gous for the screen that allows you to ad a parameter to a lookup set. by folowing this link you can see what i mean, it gets interesting after 30 seconds.
[URL]
Is there a variable that decides where on your screen you see these screens?
Quite often I will copy and paste some files out of an older project and move it to a new folder. Any file being x-ref'd is still pointing to the old location as it have saved the full path.
Is there a way to not let it save full path? When I copy and paste the files to the new folder I would like the x-ref's to default to the new location. If I cannot I need to detach several x-ref files and reattach them and rearrange it all again.
Is there any way that values in BOM columns would automatically change depending on the characteristics of the part?
Example:
I have a parametric metal rod that depending on its length has a different part number assigned to it in our company's catalog.
When I change its length in parametric assembly (50" rod is has different number than 70" rod) I want the part number to change as well in the "part number" column.
changing some properties default value for 2 items i have here. I want to keep the new settings inside my dwg template but i don't find any why to do it yet.I have to modify these manually or use match properties.
THE TEXT: Has the first picture, i would like to keep the setting Line Space Style: "Exactly" instead of "at least" all the time, each time i open a new autocad. How can i modify this default value? is there a way to do it ?
THE LEADER: Has the picture, in my dimension style i use 2 mm standard closed filled arrow. BUT i like to use the "dot" style sometimes but i like to use the dot at 1 mm not 2 mm.
Is there a way to set individually each type of leader tip size ? With dimension style override it's not working for now..Or maybe if i could change the default properties value for the particular dot in a configuration file?
Whenever I add a block property table the window that should be opent doesn't open. The strange thing is that I think it actualy is open but i just don't see it on my screen. The same thing gous for the screen that allows you to ad a parameter to a lookup set. by folowing this link you can see what i mean, it gets interesting after 30 seconds.
I am starting with a polyline then i use the pasteblock command to insert that polyline as a block.Now i can pull up the property box and change the xyz scale.
I would like to know how to change these setting in my lisp.The scale will be x=1 y=0.1 z=1
I'm having trouble changing a reference part back to normal. It's in a sub nested 2 levels. I earlier had it as a phantom but changed it easily to reference. Now I need it to be normal.
I've tried going into each level to change it. I cannot access it unless I change the BOM to read "Model Structure" since reference parts don't show up under BOM structure. When I click on Reference (it has a little X in it) it will seem like it's going to change but turns back to ref every time.
I went into the lowest sub & was able to change the part to Default through Properties but it just goes to reference again in the main assembly.
I'm trying to create all kinds of functions on an external .js file, so I can just call them in Edge multiple times with less coding. The thing is, after importing jQuery and my external Javascript file, some code works, but I get stuck at this part: changing the .css property of a symbol, more specifically, the "font-size" property. My current function is:
function setFont(textid,fontsize,originalWinWidth){ //textid: symbol's name; fontsize: current font size of this symbol; originalWinWidth: window size at the start of the animation console.log("Set Font:"); //set the original font size var originalFontSize = Math.round(originalWinWidth/fontsize); console.log("Original Font Size: " + originalFontSize); console.log("Text ID: " + textid); //set the font size using jquery sym.$(textid).css("font-size", originalFontSize); }
I get an error at the last line, all other parts of the code works.
I have a weird problem with exploding block reference with vb.net as follows.
When I use BR.explode(DBObjectCollection), and append the entities in the object collection to model space,
the 3d Polylines inside the block reference do not get appended and I do not get any kind of error. The reason for this eludes me as of yet. (remember, simple polylines and lines and other objects do get appended to model space)
When I use BR.explodetoOwnerSpace(), the block reference explodes as it normally is expected to, but then I have no way to collect the objects from the exploded BR.
I'm working with two different drawings to import Layers for Lot Grading and when I'm importing the Block Reference from the origin file, it's setup as Linescale 0.5, but when I import into my regular basemap, which is setup for Linescale 1, the text size is double what it should be.
I'm trying to write a vb script to extract information from the CAD drawing. While testing, i found that for some drawing blocks, the corresponding AcadBlockReference Rotation returns 1.57, but when i look at the actual drawing, block properties, the rotation is 0.
i need to use something with similar effect to Editor's method SelectCrossingWindow, but i need it to select object in Block Reference. How can i do that?
I have a block reference in a dwg that is a like a form, for example:
Written By: Diogo Author: Diogo
Date: 13-07-2012 State: Check-in
In autocad this is a block, and on the attributes of the block reference I only can edit State and Author, and i would like to get all values. Because i want to fill those values of Written By, Author, Date and State by code. I can reach the attribute collection of the block but i only can see the State and Author.
How to change the Scale Uniformly property in dynamic blocks accross hundreds of drawings using either/or scripts, lisp, vba or anything else that might do the job.
I just need to open the drawing and select the block (one block per drawing) then edit the scale uniformly property within the block, save then close the drawing and move onto the next drawing.