Quantcast
Channel: MicroStation Programming Forum - Recent Threads
Viewing all articles
Browse latest Browse all 7260

RE: Abstract Vertices Coordinates

$
0
0

Hi John,

a few comments:

  • Please don't post the same question to more (sub) forums! It causes confusions only. If a question is accidentally created in a wrong forum, you can ask to move it to another one.
  • Read and follow Programming Forum best practices and use correct subject format etc.
  • Accordingly to the best practices, share important information, especially what MicroStation version (build number) do you use.
  • Use Syntaxhighlighter tool (yellow pencil icon) and set a correct language when posting any code snippet.

[quote user="-"]how to extract all its vertices coordinates?[/quote]

Dim vertices() As Point3d
vertices = oElement.AsVertexList.GetVertices()

The code is correct, mostly. In my opinion it's a bad style to cast general Element object to a specific one using "As*". If working with line string only, more robust code would be similar to this:

Dim el As Element
set el = ... // obtain an element

If (el.IsLineElement) Then
    Dim line As LineElement
    Set line = el.AsLineElement
    
    Dim vertices() As Point3d
    vertices = line.GetVertices()
End If

It can be extended to a general form whether not only line string should be used as an input element:

If (el.IsVertexList) Then
    Dim vertexListElement As VertexList
    Set vertexListElement = el.AsVertexList
    
    Dim vertices() As Point3d
    vertices = vertexListElement.GetVertices()
End If

[quote user="-"]But all Micro Station VBA help examples are not clear at all[/quote]

MicroStation VBA examples demonstrate how to use a specific class or method, not where to use them, because a decision about VBA application architecture is a responsibility of developer.

[quote user="-"]which code to write in the module and which code to write in the class module[/quote]

With all respect, it's not the question related to MicroStation VBA API, because API can be used both in normal VBA code (from module) or in class definition code. It's a developer decision how the code will be structured and if classed will be used or not. There are several situations where you have to create a class to use MicroStation VBA functionality (IPrimitiveCommandEvents and ILocateCommandEvents objects), but the most of MicroStation VBA macro can be written as normal module code.

I recommend to check general VBA tutorials like www.cpearson.com and also use Google to find articles about the difference between normal and class VBA modules.

With regards,

 Jan


Viewing all articles
Browse latest Browse all 7260

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>