Jump to content

VBA limitations


GreenBee

Recommended Posts

It'd really help me if you translated the comments and prompts (there are quite a few of them) into English at least .

And, with reference to the drawing you posted, give me the values you usually start with when the routine asks for them (txtRazProf, txtSirCest in the UserForm and PocToc and ZadToc with Autocad prompts) along with their exact meaning.

 

bye

Link to comment
Share on other sites

  • Replies 26
  • Created
  • Last Reply

Top Posters In This Topic

  • GreenBee

    12

  • RICVBA

    7

  • BlackBox

    4

  • Tyke

    3

Top Posters In This Topic

Thinking out loud... Does VBA have an equivalent for Visual LISP's vlax-Curve* functions? :unsure:

 

No BB it doesn't. There are a load of things available in VLisp that are not available in VBA. As a rough rule of thumb if it's not in VB.NET then it's not in VBA. At least that's my experience up to now, but I could be wrong.

Link to comment
Share on other sites

txtRazProf = 50 - distance between cross sections

txtSirCeste = 6 - width of the road

PocToc - pick first point on the route (starting point 0+000,00)

ZadToc - pick last point of the route (end point)

 

********GLAVNI DIO PROGRAMA********

MAIN PART OF THE CODE

 

>>>>

LINE

 

Ako pravac nije prvi element trase

If line is not the first element of the road

 

Za sve ostale profile

For all other cross sections

 

Za predzadnji profil na pravcu

For penultimate cross sections of the line

 

Ako je pravac zadnji element trase

If line is the last element of the road

 

Ako je duljina pravca manja od Lostatak

If the length of the line is smaller than Lostatak

(Lostatak is the value that should be transferred to the next element, translation would be something like residual length)

 

Ako je pravac prvi element trase

If the line is the first element of the road

 

Za prvi profil na pravcu

For first section of the line

 

Provjeriti je li razmak profila manji od duljine pravca

Check if distance between cross sections is smaller than the length of the line

 

Ako je duljina pravca manja od razmaka profila

If the length of the line is smaller than the distance between cross sections

 

>>>>

transit curve (clothoide)

 

Ako prijelazna krivina nije prvi element trase

if clothoide is not the first element of the road

 

Prva tocka prijelazne krivine

First point of the clothoide

 

Ostali profili na prijelaznoj krivini

Rest of cross sections on clothoide

 

Ako je prijelazna krivina zadnji element trase

If clothoide is the last element of the road

 

>>>>

Arc

 

Ako luk nije prvi element trase

If arc is not the first element of the road

 

Ako je startpoint luka jednak drugoj tocki

If startpoint of an arc is equal to ''DrugaTocka''

(''DrugaTocka'' is the last point of the previous element, translation would be SecondPoint)

 

Ako je endpoint luka jednak drugoj tocki

If sendpoint of an arc is equal to ''DrugaTocka''

 

pocetna tocka luka

First point of an arc

 

sredisnja tocka luka

Midpoint of an arc

 

Ostali profili na luku

Rest of the cross sections on arc

 

Ako je luk duzi od razmaka profila

If arc is longer than the distance between cross sections

 

Provjeriti da li je luk zadnji element trase

Check if arc is the last segment of the road

 

Provjeriti da li je luk prvi element trase

Check if arc is the first element of the road

 

The rest of them just repeat the previos ones. Hope this helps

Link to comment
Share on other sites

@ GreenBee

 

here you can find attached the revised code.

You can find the revised and/or new codelines with side comment "RICVBA"

 

try and let me know

if it works for you, I'd gladly share with you some programming issues

 

bye

RICVBA

Road.dwg

Link to comment
Share on other sites

I really don't know how to thank you. You had obviously spent a lot of time trying to debug my code. Thank you, really. It seems to work fine.

 

But I don't understand how did your changes made it work because I haven't noticed any major changes in the code. I would like to hear about if you're willing to elaborate it.

 

Thanks again, I really appreciate your help.

Link to comment
Share on other sites

I really don't know how to thank you. You had obviously spent a lot of time trying to debug my code. Thank you, really. It seems to work fine.

 

But I don't understand how did your changes made it work because I haven't noticed any major changes in the code. I would like to hear about if you're willing to elaborate it.

 

Thanks again, I really appreciate your help.

 

 

Glad it works

the decisive changes, minor indeed, are:

1) use of "/" operator instead of "\" togheter with correctly declaring "BrPomaka" and "BrProfila" variables as integers. as, for instance:

'Dim BrProfila, i, n As Integer
Dim BrProfila As Integer, i As Integer, n As Integer, iWhat As Integer 'RICVBA
...
'                        BrProfila = (LINE.Length - Lostatak) \ RazProf
                       BrProfila = (LINE.Length - Lostatak) / RazProf 'RICVBA

 

2) the initialization of "PlusMinus" variable at the beginning of the AcDbPolyline and AcDbArc code sections

                PlusMinus = False 'RICVBA

 

3) using a less strict matching criteria to decide whether two points were to coincide.

note: my fault I missed to underline this change with the "RICVBA" side comment. sorry.

 

point 1) to fix what occurred during a "BrPomaka" handling in the "'For penultimate cross sections of the line" part of "AcDbLine" code section, in that it resulted in a integer number one less than it should (and two less than the integer part of the corresponding "kolicnik") so that subsequent "linija" moving was not sufficient to have it intersect with "Krug" circle. This did not generate any "sjeciste2" point, making PopLin setting instruction fail.

I didn't, and actually still don't, know the use of "\" operator but, from what BrPomaka was bound to be used for, I supposed it had to isolate some integer part of a number and that's why I substituted it with the "classic" division operator and having its outcome truncate by assigning it to an integer variable. And for this latter purpose I had to explicitly declare that variable as an integer, while its original declaration resulted in a Variant one (in a "Dim" instruction after every variable name you have to explicitly declare its type or it'll be implicitly taken as a Variant type).

And, seeing it worked, I extended this "treatment" to every similar occurrence in your code.

 

point 2) to emend a piece of code you clearly simply forgot about, since you had put it at the beginning of the "AcDbLine" code section, but not in following ones.

 

point 3) occurred only once, but I decided to extend this change to each and every comparison instruction. may be you'll have to think about the precision your users must deal with and consequently set your code and/or their operating standards.

 

 

 

Besides what above here you are some considerations of mine (and I warned you about that!) I think could make your software even more effective than it is (and it is already really fine)

I noticed that:

1) the user has to select drawing elements (lines, polylines, arcs) in the correct order as they follow each other along the road. So missing an element (and I guess sometimes could be very tiny) or selecting some of them in a not consecutive sequence, would result in program failure;

2) when managing polylines, the section are drawn perpendicular to segments joining polyline points rather then to its actual layout;

3) most pieces of code are quite recurring.

 

so I'd suggest the following:

a) have the user select the road elements in any order he'd liked to do that

for instance with a window selection;

b) explode polylines.

this way you'll have to manage only line and arc elements

c) process elements and order them from the first to the last one

for instance this could be done managing their initial and final points. the first and last elements being identified as the ones with either their first or last point not in common with any other element first/last point.

d) write subs for

- recurring pieces of code (moving lines,

- the "treatment" of lines and arcs

this would give you much more control over your software, since you'd be forced to think about and manage limit cases. and will have you much more effective in maintaing it.

 

if you decided to go on with some of those suggestions, I'd gladly go on helping you.

 

bye

Link to comment
Share on other sites

You guessed correctly, operator \ is integer division. I wasn't aware of my incorrect declaration of variables, thought it was enough to put them in same line. That was a significant mistake.

 

I don't have access to my original code right now but I surely forgot about PlusMinus variable because it was my intention to set to False for start of each element.

 

When I was debugging my code, everytime I checked the coincidence of two points they were complementary for the 10 decimal spaces so I guessed checking for first four or five would be OK.

 

Regarding your suggestion, I would like to go on with them and implement them in my code.

 

1) My method of selection is a bit sloppy and can be irritating but it was something I could live with. But you have a valid point, it would be much easier to just select them all at once.

 

2) I've already finished a routine to draw a horizontal curve between two tangents consisting of an arc and two splines. I didn't know how to use splines in this code so I decided to convert them polylines (by flatten command) and go on with polylines. I know there are perpendicularity issues but I accepted that relatively small error (road designs are mostly plotted in higher scales so it would be hard to notice that imperfection.

 

3) I'm aware of that and would gladly make my code more logic and easier to go through by writing procedures for parts that are repeating but my knowledge of VB is limited and I didn't know how to go through with it.

 

Thank you for thorough review.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...