Where could I find the documentation for any classes/objects/methods/etc. for accessing InRoads via VBA? Is there such a thing?
Thank you.
Where could I find the documentation for any classes/objects/methods/etc. for accessing InRoads via VBA? Is there such a thing?
Thank you.
As I learned recently, installing a default Viz Studio 2015 does not install all C++ features. You have explicitly to select them. If that surprises you (it did me) then visit discussion groups that deal with Viz Studio to read plenty of posts about that.
Robert Hook pointed out here that while installing Viz Studio 2015 we need to choose Windows and Web Development | Universal Windows App Development Tools. That advice may not be clear, so I took a few screenshots...
[quote user="Jon Summers"]I'm biased because I choose not to develop for MicroStation V8i using C#.[/quote]
Well, I have to confess I was more "forced to choose" than I choose it ;-)
But both for V8i and CONNECT Edition I consider to use both C# and C++ (with C++/CLI as a glue between both worlds) as the best solution, even though the code and architecture is usually a bit complex:
Regards,
Jan
用 “查询材料” 命令可以查到 “智能实体面包含材料****",但是用 mdlMaterial_getInternalAttachedMaterialElementId、mdlMaterial_getExternalMaterialAttachment 都无法获得材质信息。请问有没有办法可以取到这种情况的材质信息?附件是一个测试样例,谢谢![View:/cfs-file/__key/communityserver-discussions-components-files/343173/t26_2D00_4.dgn:940:0]
Hi Nick,
Per Jon and Jan's recommendation, C++/CLI is likely the most efficient and effective way to bridge your calls between native and managed code APIs.
ProStructures .NET Add-ins (ProSteel and ProConcrete, Assembly: ProstructuresNet.dll) can leverage any MicroStation APIs (MDL: C/C++ Native and .NET Managed, or MicroStation VBA), along with any Microsoft APIs required. A couple useful links for ProStructures related Programming resources currently include:
HTH,
Bob
Thank you for this. What determines the default logical name of the files?
I am using Microstation through a specific DOT user and i'm not sure if the default logical names are stored anywhere. In order to run a macro I have to open the files in a nonDOT user microstation (default).
From your post i made this:
Sub SetLogNameAsDefLogName()
Dim att As Attachment
For Each att In ActiveModelReference.Attachments
If att.AttachName <> "0014132SIGN.dgn" Then
att.LogicalName = "SIGN"
att.Rewrite
End If
Next
End Sub
But it changes every reference to logical name SIGN. Is there a way to do this for every specific reference file listed below (logical names are correct in picture)?
Hi Taylor,
[quote user="Taylor Brownlow"]Is there a way to do this for every specific reference file listed below (logical names are correct in picture)?[/quote]
Probably yes, but you still have not defined any rules how the logical names should be changed. With all respect, the picture is not any definition.
I have to repeat my question posted earlier: Is the rule about to remove (strip) all numbers from a file name beginning and the remaining part to change to uppercase?
With regards,
Jan
This will check for blank logical names and replace them with the last four characters of the base filename (no extension).
Sub SetLogNameAsDefLogName() Dim att As Attachment Dim NewLogicalName As String For Each att In ActiveModelReference.Attachments NewLogicalName = Left(att.AttachName, Len(att.AttachName)-4) If att.LogicalName <> "" Then att.LogicalName = NewLogicalName att.Rewrite End If Next att End Sub
You could add aditional tests, too.
Hi Taylor,
in my opinion Chuck's code is not robust enough, because it works for 4 characters after the digits only, which has not been defined it will be always true.
You can adapt this example to have flexible and robust code. The first function remove all leading numbers, the second one converts all characaters in string to uppercase.
Private Function StripLeadingNumbers(inputText As String) As String Dim textLength As Long textLength = Len(inputText) Dim position As Long For position = 1 To textLength If Not IsNumeric(Mid(inputText, position, 1)) Then Exit For End If Next StripLeadingNumbers = Mid(inputText, position, textLength - position + 1) End Function Private Function ConvertToUpperCase(inputText As String) As String ConvertToUpperCase = UCase(inputText) End Function Public Sub ExampleStripAndConvert() Dim text As String text = "314159268MyReferenceFile" Dim outputText As String outputText = StripLeadingNumbers(text) outputText = ConvertToUpperCase(outputText) MsgBox "Striped and uppercased: " & outputText End Sub
With regards,
Jan
Sorry, but I only updated your code, no testing was performed.
Sometimes, once you have the MicroStation VBA part working, Google is the best way to get "generic" VBA help.
I found this link is a few seconds: http://vba-tutorial.com/parsing-a-file-string-into-path-filename-and-extension/
The other part would be to get rid of the project number portion of the file name. That would be a Right(NewLogicalName, 4), except for an extra test to see if that returns YOUT, which means your filename contains SHEETLAYOUT and would need to use an 11 instead of a 4.
If your project numbers are always 7 characters, you could use Len(NewLogicalName)-7 to get the length of the string needed for the Right function.
I like Jan's addition. He clearly spent more time looking at this.
As long as you are updating reference attachments, you might want to consider updating reference file descriptions as well.
That would require a multiple test (See Select Case ... End Select) where once you know the upper case logical name, test it against a list of known logical names and revise the reference file description to correspond with that file type.
In for a penny, in for a pound, as they say.
I forgot to remove the file extension, so one extra function is required:
Private Function StripLeadingNumbers(inputText As String) As String Dim textLength As Long textLength = Len(inputText) Dim position As Long For position = 1 To textLength If Not IsNumeric(Mid(inputText, position, 1)) Then Exit For End If Next StripLeadingNumbers = Mid(inputText, position, textLength - position + 1) End Function Private Function ConvertToUpperCase(inputText As String) As String ConvertToUpperCase = UCase(inputText) End Function Private Function RemoveFileExtension(inputText As String) As String RemoveFileExtension = Mid(inputText, 1, Len(inputText) - 4) End Function Public Sub ExampleStripAndConvert() Dim text As String text = "314159268MyReference.dgn" Dim outputText As String outputText = StripLeadingNumbers(text) outputText = RemoveFileExtension(outputText) outputText = ConvertToUpperCase(outputText) MsgBox "Striped and uppercased: " & outputText End Sub
With regards,
Jan
I'm attempting to update text on a drawing using an old "company" .rsc font into a TrueType font. I have a few instances where we have used "special" symbols assigned to locations in the .rsc file (e.g. a "Working Plane" symbol). I (think) I can "convert" this symbol by building a text node with the "components" of the symbol, and providing the origins for the various pieces. If I have a single part TextBlock, does inserting/appending a LineBreak "convert" the text into a Text Node?
Thank you Jan! I run the macro, replacing "myreference" with the real file. Am i to add the previous logical name code?
Hi Taylor,
[quote user="Taylor Brownlow"]I run the macro, replacing "myreference" with the real file. Am i to add the previous logical name code?[/quote]
my code is an example how to manipulate with strings (strip leading numbers, remove last 4 chars, capitalize). I thought it's obvious it's now your responsibility to use these functions in your code. In my opinion nothing in my code should be changed, the functions are ready to be used, the main sub is only necessary minimum to deonstrate how the functions work.
With regards,
Jan