質問

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

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

I've been able to create the Leader-line in .NET using

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

The arrId I got from using the function found here, but I've been unable to figure out how to set the color of the leader to white (it shows up as red by default), and also how to set the size of the arrowhead. If anyone could help me out with this I would be most grateful.

役に立ちましたか?

解決

Ok, after a lot of trial and error, I figured out that the solution was rather simple. I didn't have to override any dimension styles (which I honestly don't even know what is, I had a short beginners course in AutoCAD before getting handed this project), I simply had to set an obscure property on the Leader-object. For future references, and for anyone else trying to do the same, here's the properties I ended up using:

leader.Dimclrd
The color of the leader-line. Stands for something like "dimension line color".
leader.Dimasz
The scale of the leader-head.

他のヒント

As type BlockReference, it should have a color property and the property should be an Autodesk.Autocad.Colors.Color or an Integer. Also the reason you are getting the object for read is, in your transaction you are opening the database with

OpenMode.ForRead

And that is correct. But to edit the object in the database, you must retrieve the object like below

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

This is done inside of the

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

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

You may want to see if there is a scale property, as to change the size.

Hopefully this will move you in the right direction.

Let me know if you have any problems. :)

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top