Changing the color of a leader in AutoCad - vb.net

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. :)

Related

Roslyn context.SemanticModel.GetDeclaredSymbol() returning NULL from InvocationExpression

Trying to develop an VS extension to help with migration from vb6 to Vb.net using Roslyn.
Unfortunately I am not having much luck with detecting the "DoEvents" expression in my source as I get NULL from my GetDeclaredSymbol during the detection.
My bad coding is......
Register the action:
context.RegisterSyntaxNodeAction(AddressOf ExpressionStatementDec, SyntaxKind.InvocationExpression)
Try and detect the "DoEvents" expression:
Private Sub ExpressionStatementDec(context As SyntaxNodeAnalysisContext)
Dim GotYou = context.SemanticModel.GetDeclaredSymbol(context.Node)
Dim WhatExpression = context.Node.ToFullString.ToString
' Find DoEvents.
If RemoveWhitespace(WhatExpression) = "DoEvents" Then
Dim diag = Diagnostic.Create(Rule, GotYou.Locations(0), GotYou.Name)
context.ReportDiagnostic(diag)
End If
End Sub
I have tried loads of options for trying to get the right type of object for "GotYou" but no luck so far.
Any pointers appreciated :)
Edit Additional info:
I have tried GetSymbolInfo but when I am detecting "DoEvents" in the context.Node.ToFullString.ToString I am still not getting anything in the context.SemanticModel.GetSymbolInfo(context.Node) as below.
Thanks,
Richard
If you want to look at what a invocation is referencing, call GetSymbolInfo not GetDeclaredSymbol.
Don’t have Visual Studio handy in order to get the code, but...
I believe what you want is something like:
Dim WhatExpression = TryCast(CType(context.Node, InvocationExpressionSyntax).Expression, IdentifierNameSyntax)?.Identifier.Text
This isn’t all of it, you could be dealing with a memberaccessexpression, in which case it’s probably not what you are looking for. The options would be a bit easier to handle with pattern matching in C#, but that’s the general idea. You don’t need the semantic tree at this point, because you first want to verify that you are dealing with the right text. Once you’ve got that, you can see where it comes from and whether it is something you need to deal with. Getting the semantic model is expensive, no reason to do so when (outside of your unit test) it is rarely going to be needed.

If statement on global variable doesn't execute function gotoAndStop();

I'm making a simple concept game, in which I've made buttons which are targets, when the user clicks said targets, it executes this code:
on (release){
_global.targetCount++;
Target1._visible=false;
if(_global.targetCount==3){
gotoAndStop(4);
}
}
the global variable was declared on the frame like this:
_global.targetCount = 0;
and the buttons do disappear when I click on them like they should, but as soon as I click the final 3rd one and it disappears, it doesn't successfully check that the if(_global.targetCount==3) and proceed to the 4th frame.
I've tried declaring the variable differently like so:
var targetCount:Number = 0;
also tried doing it like this but on using the check code button it said my syntax was wrong:
var _global.targetCount:Number = 0;
and calling every instance as just targetCount, but that didn't fix it either,
I've searched and tinkered with the code, but I can't find clear examples on global variables, the little I've used here I found by reading this:
https://www.kirupa.com/developer/actionscript/tricks/global.htm
So I was wondering if anyone here could help me by letting me know the many mistakes I've done, and how to improve them.
All help is gladly appreciated!
Every keyframe on stage is new closure. If you have variable on frame 2 and you want change/set or read value of this variable on frame 3, that variable does not exist and it is undefined. If you will try increment that undefined value you get NaN and gotoAndStop(NaN) doing nothing.
Insert trace(_global.targetCount); between _global.targetCount++; and Target1._visible=false; for debug.

How to set a required reasource location as a variable?

I'm currently making a game for an Advanced Higher computing course. After having my previous question answered perfectly and helping me a great bunch. I was wondering if you could share you wisdom upon me once again...
I've currently declared the variables, got the selection process narrowed down. All I'm sturggling to do is for it to recognise it's a variable and not the location itself.
UsedTile = My.Resources.Token(Turn)
CurrentTile = My.Resources.Colour(Turn)
I should also mention that UsedTile and CurrentTile are declared as Image so that it works with the rest of my progam.
Token is an array that swaps between 1 & 2 which is defined by Turn.
Sorry if i'm explaining this baddly, but basically I would want it to look something like
UsedTile = My.Resources.(Colour(Turn))
So that it is interchangable. All of the reasources are there, so for instance it would be a red tile it should show as
UsedTile = My.Resources.ColourRed.png
Thanks, I hope I've made it understandable. I'd happily upload more code if needed :)
-Lewis
It's a little unclear what it is that you are asking, but here are two suggestions that may help you. First, you may want to consider reading the resources once and storing them in some other data structure that makes them more convenient to access when you need them later. For instance, if you created a class like this:
Public Class ColourResources
Public Property TurnImages As Image(2)
End Class
Then you could create an array of them and fill them like this:
Dim colors(2) As ColourResources
colors(0).TurnImages(0) = My.Resources.ColourRed
colors(0).TurnImages(1) = My.Resources.ColourRedUsed
colors(1).TurnImages(0) = My.Resources.ColourBlack
colors(1).TurnImages(1) = My.Resources.ColourBlackUsed
Then when you need a particular image, you could just access in some way similar to this:
Dim tile As Image = colors(currentColor).TurnImages(currentTurn)
If your colors and turns are kept track of with some data type other than an Integer, you could use dictionaries instead of arrays.
My second suggestion is that it is possible to get the resource by string name rather than via resource-designer-auto-generated property. For instance, instead of this:
UsedTile = My.Resources.ColourRed
You could also access the same image like this:
UsedTile = DirectCast(My.Resources.ResourceManager.GetObject("ColourRed"), Image)
Depending on your needs, that may be useful to you.

Stimulsoft code based variables won't show their value

I´m losing my mind here, I've tried every example I've found online and still can't get it to work, this is the way im creating the variable on the code that generates the report, I'm working on a .NET application:
report.Dictionary.Variables.Add(New Stimulsoft.Report.Dictionary.StiVariable("test",""))
report("test") = "ANYTHING"
While it does show me the created variables on the Stimuloft gui, it contains absolutely nothing, any ideas on what I'm doing wrong? Thanks!
You should use next code to set value of variable:
report.Dictionary.Variables("test").Value = "ANYTHING"
The code that you use will work after calling report.Compile() method only.

getting the value of the boundfield in a gridview

I have encountered something strange.
I wanted to have the value of my gridview boundfield so I did this.
SelectedID = objGridView.Rows(0).Cells(4).Text.ToString
At first this seemed to work. I played around a little created a hyperlinkfield wanted to get that value but got an empty string. After some looking around it turned out I could not get it as easily as I could with a boundtextfield. No problem.
But here comes my problem , now all of a sudden my line of code to retrieve the value from the selectedId does not work anymore ( at least I'm getting empty strings back ).
I've build and rebuild my gridview but to no avail.
I'm flabbergasted and don't get it why it doesn't work anymore.
Hence my question.
Does anyone have an idea what's happening or have a solution to this problem.
edit:
I'm seeing this in my item value
"In order to evaluate an indexed property, the property must be qualified and the arguments must be explicitly supplied by the user"
Don't know why you dont use the datagridview.
I started with GridView as well but after changing the control type it's really easy to get those values e.g:
SelectedID = dgvExample.CurrentRow.Cells("Columname/Index").Value
dgv compared with gv
There is an answer here
An other one (which was the reason of my problem) could be that the BoundFields are set to Visible = false. Invisible Bound fields are... not bound.
A simple workaround is to make it invisible in CSS instead.
Code behind :
gvColumn.ItemStyle.CssClass = "className"
CSS :
.className { display:none; }