AutoCad Leader Color Change

I'm currently working on converting a VBA AutoCAD application to VB.NET, and the current team I'm working on is creating a simple leader with this code:

Set leaderObj = ThisDrawing.ModelSpace.AddLeader(points, blockRefObj, leaderType) leaderObj.ArrowheadType = acArrowDotSmall leaderObj.ArrowheadSize = 2.5 * varDimscale leaderObj.DimensionLineColor = acWhite 

I was able to create a Leader line in .NET using

 Dim l = New Leader() For Each point In jig.LeaderPoints l.AppendVertex(point) Next l.Dimldrblk = arrId 

arrId I got from using the found function here , but I was not able to figure out how to set the leader color to white (by default it is displayed in red), and also how to set the size of the arrow. If anyone could help me, I would be very grateful.

+4
source share
2 answers

Well, after many trial and error, I realized that the solution was quite simple. I didn’t have to redefine any measurement styles (which I honestly don’t even know what is, I had a short beginner course in AutoCAD before I got this project), I just needed to set the implicit property on Leader - an object. For future references and for those trying to do the same, here are the properties that I ended up with:

< D >> leader.Dimclrd dt> The color of the leader line. Stands for something like a "dimension line of color." < Dt > leader.Dimasz dt> Scale of the head of the head. For>
+2
source

As a BlockReference type, it must have a color property, and the property must be Autodesk.Autocad.Colors.Color or Integer. Also the reason you get the object to read is because in your transaction you open the database with

 OpenMode.ForRead 

And it is right. But to edit an object in the database, you must get the object, as shown below.

 var obj = Thetransaction.GetObject(theobjectid,OpenMode.ForWrite) as BlockReferance; 

It is done inside

 using(var trans = TransactionManager.StartTransaction()){} 

I do this on a cell, so check the camel case and syntax, because I write in C #, but it should be pretty close.

You might want to know if there is a scale property to resize.

Hope this moves you in the right direction.

Let me know if you have any problems. :)

+1
source

Source: https://habr.com/ru/post/1489920/


All Articles