Visio Guy

Visio Discussions => General Visio => Topic started by: markem on April 18, 2014, 06:00:11 PM

Title: Change the size of a ink drawn line
Post by: markem on April 18, 2014, 06:00:11 PM
Some years ago I tried to figure out how to make naturally looking rivers in Visio.  Unfortunately - all I did was frustrate myself and then to resign myself to not being able to do it.

But now I am back.  :-)

I have a new idea that may make it possible to at last do naturally looking rivers in Visio.  (I'm still using Visio 2003 by the way!)  Here is the idea:

Idea: If you use the line tool you can only do straight lines.  If you use the pencil tool then you can do nice curves.  But if you use the INK tools (ie: Ball point pen, etc...) you can produce natural looking drawings.  These drawings have to keep track of all of those points and places where you drew the line.  What I am wondering is - can you change the width of the line being drawn from the first point to the last between each of the successive points?  For instance, let's say I have a macro that brings up a box that asks you two questions:

Q1 = "Starting Width (default = 1pt)?
Q2 = "Ending Width (default = 10pt)?

So now I have a ratio.  For every 10% (ie: The difference between 1 & 10 is 10 [not 9 because you have to include the beginning and ending sizes]) of the way along the line from the beginning to the end the line width has to change by 1pt.  This would mean that the line would start out narrow and become wider over the distance it travels.  I was doing this by hand the other day when I thought I'd ask if this was possible.

I'm of two minds on this.  First - can it be done with just the standard INK item.  Second - if not, then how hard is it to convert the line to a shape.  When I do this by hand - I get one point for every change in the line (so I wind up with A LOT of points) but then I can move the individual points around to adjust my lines.  So if you can't change the width of an INK line on a segment by segment basis - would it be possible to convert it to a shape and then change each of _those_ segment's widths?

If none of the above is possible - like say only the whole line segment can be changed (ie: the INK shape can not be changed in this fashion nor can the INK->shape be changed because all of the points comprise a single shape still) - then can the converted shape be broken up into individual line segments so that each segment can be changed?

So - first - is the above possible and second - can you give me some hints on what I need to do in order to be able to just get to the right information?  I'm not a big VBA person.  More of a PHP person.  :-)

Thanks in advance for any help you can give.  :-)

See the attachment for an example of what I mean.
Title: Re: Change the size of a ink drawn line
Post by: Yacine on April 18, 2014, 09:14:02 PM
Why not simply use a line patterns?
Put a triangle or a pyramid in the pattern and start drawing.
Title: Re: Change the size of a ink drawn line
Post by: markem on April 19, 2014, 07:50:59 PM
I've done that before and it works ok but not great.  I'm eventually looking to make the line randomize sizes increasing and decreasing according to a formulae for natually occurring rivers I developed.
Title: Re: Change the size of a ink drawn line
Post by: wapperdude on April 19, 2014, 10:49:30 PM
The line pattern is still your best bet.  The custom pattern doesn't have to be simple, you can use the freeform tool to create some random, closed shape which can be filled.  Add to that a combination of a fill and shadow (shadow with no offset), and you can get a fairly creative coloring scheme.  Not sure that you can select specific sections of a random, freeform line.

Wapperdude
Title: Re: Change the size of a ink drawn line
Post by: markem on April 20, 2014, 05:22:29 AM
Yeah - that's the biggie.  I know an INK line can be converted to Geometric shape and that Geometric shape will have one point for every change in the line.  The real question is - can you break that line up, how to do that, and then can you change the line width of each of those segments.  I'm reading up on the Visio Programming for Dummies book online.  I'm thinking of buying it even though it is for 2007 and not 2003.  I'm sure a lot of the book is still relevant to what I want to do.
Title: Re: Change the size of a ink drawn line
Post by: markem on April 20, 2014, 04:37:16 PM
I looked around and found the Microsoft SDK for Visio 2003.  It is full of examples on how to do various things in Visio.  For instance:

Public Sub DrawLine_Example()

    Dim vsoShape As Visio.Shape

    Set vsoShape = ActivePage.DrawLine(5, 4, 7.5, 1)

End Sub 


That is how easy it is to draw a line segment.  (0,0) is in the bottom left corner while (8.5,11) is in the upper right corner.  I did some reading up on being able to click the mouse and determine if it is down or up and found a very simple methodology to use.  Unfortunately, the example program given doesn't work.  It is split up in to two sections.  The first one is the class and the second is the program that goes into the location called ThisDocument.  However, the trigger for the program (Document_DocumentSaved) doesn't seem to do anything when you save the document.  That is to say that when you save the document it is supposed to trigger the program so that when you do a mousedown or mouseup or mousemove the script is supposed to tell you what you just did and instead - it doesn't do anything.  However, if I can get this to work then I can make a simple routine that would allow me to monitor key strokes also (like +/-) so I can increase/decrease the width of the line dynamically.  This would meet my needs well enough.  Make a bunch of small line segments, maybe have a minimum number of pixels/points away from the last point and to be able to increase/decrease the line width.  :-)
Title: Re: Change the size of a ink drawn line
Post by: markem on April 20, 2014, 04:52:07 PM
Ok - I'm not one to complain constantly but......

Could they use the same terms in their names in Visio internals?  The command is:

Debug.Print "Left mouse button clicked"

But the Debug Window's name is : Immediate

Makes it kind of hard to find when you are trying to see the messages that are being printed.  But at last I have found it and the mouse stuff IS working!  :-)

So now all I have to do is to try to tie the two things together (ie: Follow the mouse when it is down and make lines every X number of pixels!).  Getting closer.  :-)
Title: Re: Change the size of a ink drawn line
Post by: Yacine on April 20, 2014, 06:44:14 PM
Hi Markem,
can you send a sample of what you are trying to do?

I could not really make a sense of what you are writing.
Title: Re: Change the size of a ink drawn line
Post by: markem on April 21, 2014, 12:07:21 AM
Ok - look at the map from Google Maps.  I want to be able to draw a river segment like the one on the map.  You can not do that with Visio 2003.  Or probably any of the versions of Visio up to the present.  It doesn't conform to any of the given tools such as rectangles, circles, arcs, and so forth.  The only thing you can use is the INK pens.  But even those only do one size line.  (ie: Whatever you set it to.)  You can't use a shape in a line pattern because they either repeat or do not repeat.  if they repeat the river looks like it is from 2D world or something like that.  If you do not repeat then the line just keeps getting larger.  That is not how rivers work.  They DO eventually become larger but they grow and shrink as they move along their paths and they have islands in the streams and other such things.  This naturally occurring set of pathways can not be duplicated easily in Visio.  Photoshop - yeah.  Illustrator - with a lot of work.  Could I just draw this by hand, scan it in, and then use Visio to trace over everything?  Why?  Why should I do that?  Visio is supposed to make our lives easier.  Yet Visio doesn't have any kind of naturally occurring set of commands.

This is like the difference between Painter and PhotoShop.  PhotoShop has GROWN into being able to do/use naturally occurring paints, brushes, and such but until Painter came along - no one ever thought about making Nozzles or oil paintings ON A COMPUTER.  Scan them in - yeah sure.  Touch up digital pictures - yep - they did that.  But be able to create from the ground up oil paintings, pastel paintings, chalk, pencil, variable pressure?  Nope.  Painter had to be created before everyone went "Wow!  That's neat!" and to write the code to do this.  Now - everyone has it.  Some are better programs than others.

Visio started out as just a plain CAD program (just like Canvas did at Deneba).  It evolved a bit in 2003 and now in 2013 there are a lot of things you can do artistically that you cuold not do in Visio 2003.  Just like Canvas 5 and 7 and now whatever number it is at - Canvas is more of an artistic program rather than a CAD program.  The problem is - what made Visio so great was it WAS a CAD program that did a lot more than most other CAD programs did.  So in Visio 2013 you've pretty much lost the CAD side of things and Visio is now mostly just another art program with a side dish of CAD.  But I like 2003 because it is mainly a CAD program.

So >MY< problem is that I want those naturally occurring types of abilities.  Like Campaign Cartographer (which I do own already) - I'd like to be able to make fractal landscapes, rivers, mountains, and things like that.  Campaign Cartographer is actually built on top of FastCAD.  A CAD system from Great Britian and you get FastCAD as part of Campaign Cartographer only certain parts of FastCAD are disabled.  The problem with FastCAD is that it is a VERY old DOS program that was given Windows capabilities.  And.......it works in reverse.  Like many of the old CAD systems you have to tell it everything up front AND THEN draw your figure.  It is a real pain in the rear to learn and use because of this.  People who, in the pre-computer age - learned how to do architectural drawings love it because it works in the same manner as how they were taught.  But I like Visio because it is straight forwards.  You draw what you want and then you can modify it as you go.  Campaign Cartographer - you are kind of stuck or you have to jump through hoops to make it work the way you want it to work.  It is sort of like GIMP.  When GIMP first came out it worked the same way as Campaign Cartographer.  Everything worked in reverse to how Photoshop worked.  Then someone came along and rewrote the interface and made it work in the same way that Photoshop worked.  So GIMP then worked in drive instead of reverse (to use automotive terminology).  Now GIMP just works that way and hardly anyone remembers when GIMP was very hard to use.

So I want to apply Visio's forwards thinking way of doing things to what I would do in Campaign Cargtographer.  I want to build mountains, valleys, rivers, towns, coastlines, and the like.  I want to be able to drag out a rectangular area and have Visio create a fractalized area.  I want to be able to create a fractal coastline and have Visio layout the additional fractalized ocean depth areas.  But to be able to do all of this I have to start somewhere and that somewhere is - I want to draw a realistic looking river that Visio does the grunt work for me and all I have to do is to draw a curvy line.  Visio does the rest.  I'd also like to be able to provide some inputs into the river creation.  I want to be able to expand the river when I want to, I want it to split when I want it to split, join when I want it to join, and to be able to put islands into the middle of the river when I want it to do so.  Starting point though - is just to draw a river like I can do with the INK command only this river is made up of lots of little line segments that I can move if need be.  The DrawPolyline example is what I have been looking for.  The first part of that example creates a polyline with multiple line segments and the DrawLine example just does on line segment.  So if I keep track of the array of X and Y locations (start-stop) and how wide I want each line segments - then I have my line drawing part and all I need to do is to capture the mouse movements, the up and down of the mouse buttons, and I can pretty much do the line drawings.

After I have gotten this to work - my next thing is to modify how the lines are drawn so they are like the Google map (ie: Dark blue edges and light blue centers).  And like Google Maps - if I do this as a shape (ie: polyline) then I can zoom in as far as I want or zoom out as far as I want too.  The line would still remain the same.

Does this explain what I am doing and wanting?  :-)
Title: Re: Change the size of a ink drawn line
Post by: wapperdude on April 21, 2014, 02:34:35 PM
What you asking Visio to do isn't possible.  Visio, and most (if not all) Photo editing and drawing programs don't do fractals.  Certainly not Visio.  That was never its purpose.  For those effects, you need to import an image.  I doubt there's much demand for those features so don't expect to see them anytime soon.

Wapperdude
Title: Re: Change the size of a ink drawn line
Post by: markem on April 21, 2014, 07:34:58 PM
wapperdude:  As I said - FastCAD will do this under Campaign Cartographer.  Fractal Landscape is also used by game players, nBoss has a Fractal Terrain program, Dungeon Djinni is also a CAD program, MapX was a CAD program that handled this as well.  There is even a plug-in for AutoCAD that will do fractals.  There are well over 6 million D&D players and more than a million GURPS players.  Every year over $1 Billion dollars is spent on RPG games, accessories, and on going to conventions.  I think there is a target audience for this.  There were several small attempts to bring Visio into the RPG world but these were mainly some simple shapes to help people draw dungeons.  No one has ever done a fractal line.  Factals are what are used to create realistic flowers, coastlines, mountains, valleys, rivers, streams, trees, grass, and so forth.  The programs are fairly simple because fractals are recursive and thus - so are the programs that create them.

I'll see about posting an image when I am done with just the river drawer.
Title: Re: Change the size of a ink drawn line
Post by: Yacine on April 21, 2014, 08:10:50 PM
 Hi Markem,
I fully agree with Wapperdude, that Visio was not intended for fractals. I think the better tool for your purpose is Inkscape. It is free and has many features to make a vector graphic look more handmade.
Why? Because Visio's graphics capabilities are honestly said, limited. Its strength comes when data have to be linked to graphics.
However your request is challenging, so here are some thoughts to get it done with Visio.
1)      Rivers
a) One simple way would be to draw the line of the river with the freeform tool. An appropriate offset will give the route a width. Connect the offset lines with small line segments and join.
The so created shape can now be edited by moving the vertex points. (s. Page 1)
b) Much more interesting is to setup some macros to create custom line patterns.
Inkscape has similar tools where the shape of a line can be edited via a separate shape (https://www.youtube.com/watch?v=BDcUKT3Bclo (https://www.youtube.com/watch?v=BDcUKT3Bclo))
On page 2 I inserted some line shapes that you can be edited and inserted in duplicates of Master.x
Page 3 shows some freeform lines with these masters as line patterns.

The idea would now be to create on the fly a new pattern, whenever you need a new line. That should not be so difficult.
The big advantage over solution A, is that the path is still fully editable.
2) Fractals
I agree with your answer to Wapperdude. But that's an issue worth a separate thread and some preparation thoughts.
Title: Re: Change the size of a ink drawn line
Post by: markem on April 22, 2014, 02:09:49 AM
Ok - it took me a while to figure out the "Object Required" messages in the "Oh so helpful" help section.  And I actually finally went on line and found out what was the matter.  It turns out you can get this same message in multiple ways.  I managed to do it in two different ways.  The first way is to NOT have the word "SET" in front of assigning an object a value and the other way is to HAVE the SET command on a line where you are trying to set a variable.  So - keep that in mind if you decide to program VBA.  They reuse the same error messages for different reasons.  Anyway - here is a first whack at making it so you can draw a line out of multiple line segments.  I'm still trying to figure out how to get rid of the selection box.  But at least this work.

Main Program ( placed inside of the ThisDocument object):
Dim myMouseListener As MouseListener
Dim btnLocations(1000, 1000) As Double
Dim btnCount As Integer

Public Sub DrawLine_Example()

    Dim vsoShape As Visio.Shape
   
    Set myMouseListener = New MouseListener
   
    Debug.Print "Ready"
   
End Sub



MouseListener (taken from the CHM and modified):
Dim WithEvents vsoWindow As Visio.Window
Dim xc As Double
Dim yc As Double
Dim myButton As String
Dim btnLocations(1000, 1000) As Double
Dim btnCount As Long
Dim I As Long

Private Sub Class_Initialize()

    Set vsoWindow = ActiveWindow
    btnCount = 0
    myButton = "LU"
   
End Sub

Private Sub Class_Terminate()

    Set vsoWindow = Nothing

End Sub

Private Sub vsoWindow_MouseDown(ByVal Button As Long, ByVal KeyButtonState As Long, ByVal x As Double, ByVal y As Double, CancelDefault As Boolean)
   
    If Button = 1 Then
        myButton = "LD"
        btnCount = 0
        btnLocations(btnCount, 0) = x
        btnLocations(btnCount, 1) = y
        Debug.Print "Left mouse button clicked"
    ElseIf Button = 2 Then
        myButton = "MD"
        Debug.Print "Right mouse button clicked"
    ElseIf Button = 16 Then
        myButton = "RD"
        Debug.Print "Center mouse button clicked"
    End If
       
End Sub

Private Sub vsoWindow_MouseMove(ByVal Button As Long, ByVal KeyButtonState As Long, ByVal x As Double, ByVal y As Double, CancelDefault As Boolean)
    Debug.Print "x-position is "; x
    Debug.Print "y-position is "; y
    If (myButton = "LD") Then
        btnCount = btnCount + 1
        If (btnCount > 1000) Then btnCount = 1000
        btnLocations(btnCount, 0) = x
        btnLocations(btnCount, 1) = y
        Set vsoShape = ActivePage.DrawLine(btnLocations(btnCount - 1, 0), btnLocations(btnCount - 1, 1), btnLocations(btnCount, 0), btnLocations(btnCount, 1))
        End If
           
End Sub

Private Sub vsoWindow_MouseUp(ByVal Button As Long, ByVal KeyButtonState As Long, ByVal x As Double, ByVal y As Double, CancelDefault As Boolean)
   
    If Button = 1 Then
        myButton = "LU"
        Debug.Print "Left mouse button released"
    ElseIf Button = 2 Then
        myButton = "MU"
        Debug.Print "Right mouse button released"
    ElseIf Button = 16 Then
        myButton = "RU"
        Debug.Print "Center mouse button released"
    End If
       
    Set myMouseListener = Nothing
End Sub



Ok - if you have read this far - does anyone know why the Visio VBA editor won't scroll the edit window?  Maybe it's just a Visio 2003 thing - but I thought I remembered that the edit window scrolled via the middle mouse button up and down.  Let me know if you know how to make it do this.  Thanks!  :-)

Attached image was taken after I drew the line and then went back and selected one of the line segments.  :-)
Title: Re: Change the size of a ink drawn line
Post by: wapperdude on April 22, 2014, 02:29:27 AM
@Yacine:  You do realize that page 3 looks like a swan floating on water?   ;)   8)

@Markem:  Now that you have all of these line segments stitched together, are you then going to apply some variable width algorithm?  ...and then, all the little branching tributaries?  Phew!  Lot of work!

Wapperdude
Title: Re: Change the size of a ink drawn line
Post by: markem on April 22, 2014, 03:50:03 AM
wrapperdude:  Actually - yes.    :D

I now have it doing variable width lines as I go along.  I'm going to have to do something (probably a dialog box) that will make it so I can select whether I want the line to just increase in size or if I want it to deviate along the path.  Here is the code so far:

Main Object(in the ThisDocument)
Dim myMouseListener As MouseListener
Dim btnLocations(1000, 1000) As Double
Dim btnCount As Integer

Public Sub DrawLine_Example()

    Dim vsoShape As Visio.Shape
   
    Set myMouseListener = New MouseListener
   
    Debug.Print "Ready"
   
End Sub


Class Module
Dim WithEvents vsoWindow As Visio.Window
Dim xc As Double
Dim yc As Double
Dim myButton As String
Dim btnLocations(1000, 1000) As Double
Dim btnCount As Long
Dim I As Long
Dim myWeight As Double
Dim myDir As Long

Private Sub Class_Initialize()

    Set vsoWindow = ActiveWindow
    btnCount = 0
    myButton = "LU"
    Math.Randomize
    myWeight = Math.Rnd * 0.01
    myDir = 1
   
End Sub

Private Sub Class_Terminate()

    Set vsoWindow = Nothing

End Sub

Private Sub vsoWindow_MouseDown(ByVal Button As Long, ByVal KeyButtonState As Long, ByVal x As Double, ByVal y As Double, CancelDefault As Boolean)
   
    If Button = 1 Then
        myButton = "LD"
        btnCount = 0
        btnLocations(btnCount, 0) = x
        btnLocations(btnCount, 1) = y
        Debug.Print "Left mouse button clicked"
    ElseIf Button = 2 Then
        myButton = "MD"
        Debug.Print "Right mouse button clicked"
    ElseIf Button = 16 Then
        myButton = "RD"
        Debug.Print "Center mouse button clicked"
    End If
       
End Sub

Private Sub vsoWindow_MouseMove(ByVal Button As Long, ByVal KeyButtonState As Long, ByVal x As Double, ByVal y As Double, CancelDefault As Boolean)
    Debug.Print "x-position is "; x
    Debug.Print "y-position is "; y
    If (myButton = "LD") Then
        btnCount = btnCount + 1
        If (btnCount > 1000) Then btnCount = 1000
        btnLocations(btnCount, 0) = x
        btnLocations(btnCount, 1) = y
        Set vsoShape = ActivePage.DrawLine(btnLocations(btnCount - 1, 0), btnLocations(btnCount - 1, 1), btnLocations(btnCount, 0), btnLocations(btnCount, 1))
        vsoShape.Cells("CenterX") = True
        vsoShape.Cells("CenterY") = True
Debug.Print "myWeight = "; myWeight
        If myWeight < 0.1 And myDir > 0 Then
            myWeight = myWeight + Math.Rnd * 0.001
            vsoShape.Cells("LineWeight").Formula = "=" & myWeight
            ElseIf myWeight > 0.01 And myDir < 1 Then
                myWeight = myWeight - Math.Rnd * 0.001
                vsoShape.Cells("LineWeight").Formula = "=" & myWeight
            ElseIf myWeight > 0.1 And myDir > 0 Then
                myDir = 0
                myWeight = myWeight - Math.Rnd * 0.001
                vsoShape.Cells("LineWeight").Formula = "=" & myWeight
            ElseIf myWeight < 0.01 And myDir < 1 Then
                myDir = 1
                myWeight = myWeight + Math.Rnd * 0.001
                vsoShape.Cells("LineWeight").Formula = "=" & myWeight
            End If
        End If
           
End Sub

Private Sub vsoWindow_MouseUp(ByVal Button As Long, ByVal KeyButtonState As Long, ByVal x As Double, ByVal y As Double, CancelDefault As Boolean)
   
    If Button = 1 Then
        myButton = "LU"
        Debug.Print "Left mouse button released"
    ElseIf Button = 2 Then
        myButton = "MU"
        Debug.Print "Right mouse button released"
    ElseIf Button = 16 Then
        myButton = "RU"
        Debug.Print "Center mouse button released"
    End If
       
    Set myMouseListener = Nothing
End Sub


Right now this does variable width along the line changing the lineweight as it goes.  I can modify it so it will just increase but this is pretty neat just by itself.  However, I might want the variation in size to be different.

Ya know - you say "That's a lot of work" but think of it like this - how much work is this going to save me?  Instead of trying for hours to get a river to look right I can adjust this simple program and make something really interesting. Cool....don't cha think?  8)
Title: Re: Change the size of a ink drawn line
Post by: markem on April 22, 2014, 04:46:48 AM
Ok - last posting for the night.  I've now thrown out the dimensioned array in favor of just keeping the last line segment and I have it also going from really thin to larger.  I'm beginning to think that just going from large to small may be the only thing I need - but not sure about that.  Still - I'm including a screen snapshot of a quick and dirty river I drew.  Note that I now also have color (just blue) and can now change the color up and down as I want.  Also, all rivers start at 0.001 and go up from there.

g'night everyone! :-)

Just posting the new module

Dim WithEvents vsoWindow As Visio.Window
Dim xc As Double
Dim yc As Double
Dim myButton As String
Dim ox As Double
Dim oy As Double
Dim I As Long
Dim mw As Double
Dim myDir As Long

Private Sub Class_Initialize()

    Set vsoWindow = ActiveWindow
    myButton = "LU"
    Math.Randomize
    mw = 0.001
    myDir = 1
   
End Sub

Private Sub Class_Terminate()

    Set vsoWindow = Nothing

End Sub

Private Sub vsoWindow_MouseDown(ByVal Button As Long, ByVal KeyButtonState As Long, ByVal x As Double, ByVal y As Double, CancelDefault As Boolean)
   
    vsoWindow.DeselectAll
    ox = x
    oy = y
    mw = 0.001
    myDir = 1

    If Button = 1 Then
        myButton = "LD"
        Debug.Print "Left mouse button clicked"
    ElseIf Button = 2 Then
        myButton = "MD"
        Debug.Print "Right mouse button clicked"
    ElseIf Button = 16 Then
        myButton = "RD"
        Debug.Print "Center mouse button clicked"
    End If

End Sub

Private Sub vsoWindow_MouseMove(ByVal Button As Long, ByVal KeyButtonState As Long, ByVal x As Double, ByVal y As Double, CancelDefault As Boolean)
    rateOfChange = 0.001
    If (myButton = "LD") Then
        Set vsoShape = ActivePage.DrawLine(ox, oy, x, y)
        vsoShape.Cells("CenterX") = True
        vsoShape.Cells("CenterY") = True
        vsoShape.Cells("LineColor").Formula = "=RGB(0,0,255)"
        myRand = Math.Rnd * rateOfChange
Debug.Print "mw = "; mw
        If mw < 0.1 And myDir > 0 Then
            mw = mw + myRand
            vsoShape.Cells("LineWeight").Formula = "=" & mw
            ElseIf mw > 0.001 And myDir < 1 Then
                mw = mw - myRand
                vsoShape.Cells("LineWeight").Formula = "=" & mw
            ElseIf mw > 0.1 And myDir > 0 Then
                myDir = 0
                mw = mw - myRand
                vsoShape.Cells("LineWeight").Formula = "=" & mw
            ElseIf mw < 0.001 And myDir < 1 Then
                myDir = 1
                mw = mw + myRand
                vsoShape.Cells("LineWeight").Formula = "=" & mw
            End If
        End If

    ox = x
    oy = y
    vsoWindow.DeselectAll
End Sub

Private Sub vsoWindow_MouseUp(ByVal Button As Long, ByVal KeyButtonState As Long, ByVal x As Double, ByVal y As Double, CancelDefault As Boolean)
   
    ox = x
    oy = y
    mw = 0.001
    myDir = 1

    If Button = 1 Then
        myButton = "LU"
        Debug.Print "Left mouse button released"
    ElseIf Button = 2 Then
        myButton = "MU"
        Debug.Print "Right mouse button released"
    ElseIf Button = 16 Then
        myButton = "RU"
        Debug.Print "Center mouse button released"
    End If
       
    Set myMouseListener = Nothing
    vsoWindow.DeselectAll
End Sub

Title: Re: Change the size of a ink drawn line
Post by: Yacine on April 22, 2014, 05:49:31 AM
Quote from: wapperdude on April 22, 2014, 02:29:27 AM
@Yacine:  You do realize that page 3 looks like a swan floating on water?   ;)   8)
It's a seal.   ;)   8)
Title: Re: Change the size of a ink drawn line
Post by: markem on April 22, 2014, 06:12:22 AM
Yacine:  Nice!  I like it!  :-)
Title: Re: Change the size of a ink drawn line
Post by: Yacine on April 22, 2014, 06:26:56 AM
Quote from: markem on April 22, 2014, 06:12:22 AM
Yacine:  Nice!  I like it!  :-)
I would have prefered, that you like my previous posting.
I think, you are on the wrong path with your line segments. These drawings won't be editable anymore.
Title: Re: Change the size of a ink drawn line
Post by: markem on April 22, 2014, 06:07:36 PM
I don't know why you are saying that.  Are you afraid that there will be too many objects in the drawing?  I DO have some Visio drawings which are so huge that I can only export them as 150-200dpi jpegs.  I'm also not looking for stylized drawings.  I'm looking for something that looks like a jagged river.  Also, once I have something I can use I can always generate a PNG or JPG from the line segments.

If, on the other hand, you are thinking I won't be able to adjust the river after I have drawn it - I've already tested that and can do so easily.  I just zoom in and click on one of the line segments while holding down the shift key and once I have both line segments I can then move that point and both line segments come with me.

Remember that I am using Visio 2003.  Here is what I get using the various drawing tools:

1. Line segment - only short, straight lines.  Useless for drawing rivers
2. Arc - see #1 above
3. Freeform - great if you always want smooth, nice looking curves.  I need jagged ones.  Rivers seen from space would look nice and curvy but up close they eat away at river banks, collapse them, and leave jagged gashes here and there (one of the things I want to do later on).
4. Pencil - See #2 above
5. Inks - These will do what I want and I can convert them to a Geometric type afterwards but it has only one line width.

I know that Visio Guy posted some years ago how to do random shapes in Visio's line drawings and I tried it.  It worked ok and did the same kinds of things that you did with your example but I don't want to end up with a smooth sided object.  As I keep saying - I want a jagged object.  Being able to draw a variable width line is just the first step.  Actually - just being able to draw a line programmatically is the first step.  Then seeing how to do multiple lines is next.  Then adding in color.  Unselecting everything so you don't wind up with a selection box was another step.

Inkscape:  I have Inkscape and think it is ok.  I played around with it when it first came out and it was not all that great.  Now - it is a heck of a lot better and my hat off to them for sticking with it but it isn't Visio and I happen to like Visio as much as some people like Inkscape.  So I'm doing this in Visio.  :-)

Now - if you think what I'm doing NOW in Visio has no merit - just wait until I switch over to PHP and begin converting all of the bitmap images I have for mountains, trees, and so forth into vector images.  There are about 5,000 images and I'd like to convert all of them over.  So I plan on taking what I am learning now and apply it to that.  So why do this?  Because the way Visio works is to always make a copy of whatever it is you put in as an image.  Believe me.  I've tried making shape libraries, templates, etc....  And what I still wound up with were drawings that are over a gigabyte in size because they contain bitmap images and Visio 2003 seems to always just make a copy of the entire image instead of just making a pointer to the image and using that.  So one of the reasons I am going to do this is to see how Visio handles having detailed vector shapes.  If it works like I think it is going to work then my maps will take up a lot less space in memory and they also might be a lot more scaleable.  I'm looking at using PolyLines for those (unless it is just one dot that is a certain color - then a line segment would be used.  Too bad Visio doesn't have a point function.  It would come in handy for those kinds of things.  I may also look at the rectangle function.)

Now.  I have something to say to you, Yacine, and everyone else:  My ultimate goal is to learn the ins and outs of programming Visio 2003.  What I need is HELP.  What I do not want is to have to fight an uphill battle against anyone and everyone who wants to say "But you can do it THIS way".  I do not want to do it THAT way.  I want to learn how to program Visio to make it do what I want it to do.  If you know how to program Visio - then lend your help showing me how to improve on what I am programming.  But if all you want to do is to stop me from achieving my goal of learning how to program Visio - then please go away.  I do not need the hindrance - I need the help.  And I hate to make it sound harsh - but I'm not going to stop trying to learn how to program Visio.  I tried learning it a few years ago but gave up because VBA is just whacky in some ways.  As a programmer who started programming in 1972 - I think I know whacky when I see it.  And VBA is whacky.  So I gave up then but now VBA is making sense to me for unknown reasons and some of the whackiness is also now making sense.  Not that the whackiness is less - just I am now going "Oh.  THAT is why they did that."  So if you want to help - then help me achieve >my< goals.  Don't tell me there is an easier way to do this.  You always have to go through all of the mistakes before you learn the right way to program something.  That is just how it is with programming.  When I get done - I expect to know a lot about VBA and the inner workings of Visio.  I am looking forwards to knowing how to load images, macros, or whatever and to be able to automatically execute whatever script I need to run in order to be able to do what I want to do.  Your help in achieving this goal is appreciated.  But trying to deflect me from this goal - is not.

I do hope you who read this understand what I am saying.  I am NOT trying to be nasty and I am NOT trying to be harsh or ungrateful or anything negative like that.  What I am trying to say is "Help me achieve my goals".  Come with me, stand beside me, show me where I am making my mistakes in my programs.  Show me how I can make them better.  How I can make them run faster or smarter.  Show me - but let me make my mistakes.  It is the only way to learn what not to do as well as what to do.

Thanks!   :)
Title: Re: Change the size of a ink drawn line
Post by: Yacine on April 22, 2014, 06:46:24 PM
Quote from: markem on April 22, 2014, 06:07:36 PM
Now.  I have something to say to you, Yacine, and everyone else:  My ultimate goal is to learn the ins and outs of programming Visio 2003.  What I need is HELP.  What I do not want is to have to fight an uphill battle against anyone and everyone who wants to say "But you can do it THIS way".  I do not want to do it THAT way.  I want to learn how to program Visio to make it do what I want it to do.  If you know how to program Visio - then lend your help showing me how to improve on what I am programming.  But if all you want to do is to stop me from achieving my goal of learning how to program Visio - then please go away.  I do not need the hindrance - I need the help.  And I hate to make it sound harsh - but I'm not going to stop trying to learn how to program Visio. 

Hi Markem,
sorry for the impression my answers gave to you. I've posted so many answers in this forum, that I probably got beyond answering just the exact question posted to this forum. I, and most of the senior members here, try to think further about how the solution will evolve, how the audience will accept a solution, how this solution can be maintained, what the actual purpose is, ... etc.
Myself and others will often not tell you to just not do somtething, but how to do it better. This is legitim. We can expect this to be respected. It is only fair that everyone can  stands for its convictions.

As I wrote previously, I don't think Visio is the ideal tool for the job, but also that the task is challenging and worth working on it.

As for your wish to learn how to program Visio, we certainly can bring you to an acceptable level. All of the contributors here are very eager to share their knowledge. Some patience and "social competence" are of course helpful.

So far for the "emotional" part, the technical part to follow on further posts.
Title: Re: Change the size of a ink drawn line
Post by: vojo on April 22, 2014, 06:59:15 PM
for what its worth, if you can get the original into a EMF format, you can copy into visio and ungroup.   This will give a collection of shapes that make up the image...you can then group those shapes.  The result is a group with say 100 child shapes inside.

I agree freeform is tough....could play with the sensitivity so any twitches in your hand do not show up on the drawing

Finally, you could put image on background page....on foreground page (using the background page) zoom in to say 800%
and do trace by hand.  when done, disconnect background page in page properties

And if you really are not faint of heart, you could write some VBA to process the pixel into various geometries  ;-)
Title: Re: Change the size of a ink drawn line
Post by: vojo on April 22, 2014, 07:02:41 PM
Since you are talking inkscape....there may be some Python tools you could use to get the image to some usable form

for example, save with background transparent (so you can place things near it with no problems)
I do know there are python packages to do image processing....so maybe one of those could be extended to do this.
Title: Re: Change the size of a ink drawn line
Post by: Yacine on April 22, 2014, 07:17:55 PM
Quote from: markem on April 22, 2014, 06:07:36 PM
If, on the other hand, you are thinking I won't be able to adjust the river after I have drawn it - I've already tested that and can do so easily.  I just zoom in and click on one of the line segments while holding down the shift key and once I have both line segments I can then move that point and both line segments come with me.

Remember that I am using Visio 2003.  Here is what I get using the various drawing tools:

1. Line segment - only short, straight lines.  Useless for drawing rivers
2. Arc - see #1 above
3. Freeform - great if you always want smooth, nice looking curves.  I need jagged ones.  Rivers seen from space would look nice and curvy but up close they eat away at river banks, collapse them, and leave jagged gashes here and there (one of the things I want to do later on).
4. Pencil - See #2 above
5. Inks - These will do what I want and I can convert them to a Geometric type afterwards but it has only one line width


It's the second thought.

Editable, means (to me at least) that the user can with a reasonable effort change the document.
With your solution, single vertices can be edited. But when this solution grows up to tens, then to hundreds of vertices every user will just give up.
So the solution should have an underlaying curve that can be edited easily.

Here come the freeform (Bezier) lines and the polylines. That is something to explore furthermore.
There are several cells in the geometry section, that can be decorticated to fullfill custom purposes.

Hope that helps for a first (second?) shot,

Yacine
Title: Re: Change the size of a ink drawn line
Post by: wapperdude on April 22, 2014, 07:22:19 PM
Hey Markem...

Generally, most posters have a vague idea what they want as an end result.  As, the thread progresses and details come out, then the process matures to yield an effective, efficient solution.  Some poster's, as it develops, have very specific criteria, and just get stuck and need a process to solve their issue.  Many of those require looking at alternative methods than the approach initially proposed.  Sometimes, there are no alternatives.  But, it's a process.  Occasionally, the solution lies outside of Visio.

I think your requirements are now better understood.  A critical piece is the "jagged" look.  I suspect, your application is RPG oriented, and that in part explains your tolerance for the intensive time and effort needed.  That's not typical.  But, just as a check point, you have, undoubtedly, looked at other Terrain Fractal programs?  I googled and there does seem to be a few out there, and most geared to RPG application.  Guess that doesn't help with your need to translate existing images.

Wapperdude
Title: Re: Change the size of a ink drawn line
Post by: markem on April 22, 2014, 07:53:43 PM
Yes it does Yacine and thank you for responding!  (You too vojo and wapperdude!)   :)

Yacine : Polylines are easily done via programming but they are considered a single line and thus only one width.  But for the importing of images - yes.  They are what I believe have to be used in order to draw the images (rather than them being bitmaps).  Especially since, if the first and last points are the same - the Polyline becomes a filled shape.  So if a mountain image is mainly just grey with some black lines on it I think I can make the Polyline do all of the grey followed by the black lines on top of that shape.

wapperdude : First - where DID you come up with that name?  I've seen a lot of user names before but yours is definitely unique.  Gotcha on what you said.  I have looked at several (and bought several) programs.  None of them approach the creation of things like coast lines in the same manner in which I want to approach it and none of them do more than let you build a Polyline of a river.  So what you get is a god's eye view of the river.  But woe unto he who tries to do more because you wind up with hours of frustration.  I worked at NASA from 1989 to 2006 and one of the things I did there was to help create maps.  We used Photoshop a lot but we also did it programmatically.  So I could do this in C/C++, PHP, FreeBasic, Perl, and other languages - but I'd like it to be in Visio which means I have to learn VBA.  Because I don't want it to just be an image and I don't want to write my own CAD system.  :)

I am including an example tavern.  Note the tavern looks really nice but the alcoves to the northeast are just added on so people can see where it is located.
Title: Re: Change the size of a ink drawn line
Post by: wapperdude on April 22, 2014, 08:22:17 PM
 ;D  Well, the name kinda morphed into being.  Initials are WAP.  Work associate used to call me WAPPER.  I'm from Los Angeles, dude.  And, it's unique so no dumb numbers, as if I'm Wapperdude317.

I'm kind of surprised that the RPG community and the fractal orgs don't have something more suitable.  After all, it is 2014!!!

With all your effort, hope Visio and VBA don't end up being a dead end.

Wapperdude   ;)
Title: Re: Change the size of a ink drawn line
Post by: markem on April 22, 2014, 11:27:24 PM
Here is a little something I have already done in Visio for a friend.  The hand drawn map and the Visio map.  :-)

Note on the color map that I used various shades of blue on the INK lines as well as changing the width of the lines as I went.  This is one of the things I want to avoid having to do in the future.
Title: Re: Change the size of a ink drawn line
Post by: wapperdude on April 23, 2014, 02:54:07 AM
Well...guess I'm still not convinced that Visio is the way to go...perhaps I'm blurring the distinction between a map vs actual landscape rendering.  So, in the latter category, this looks really promising:  http://www.world-machine.com/ (http://www.world-machine.com/).

In the former category (maps):  this link list a bunch, including your Campaign Cartography, but many more, including fractal based entries:  http://www.wherethemapends.com/writerstools/writers_tools_pages/world_builders.htm (http://www.wherethemapends.com/writerstools/writers_tools_pages/world_builders.htm)

So, when you take a break, perhaps there's something of interest.

Wapperdude


Title: Re: Change the size of a ink drawn line
Post by: markem on April 23, 2014, 04:45:01 PM
Ok - I looked at World Map/Maker - you don't get to say where things go.  It is more of a "Hey!  Look!  A new world!" kind of program.  You can give it such things as mountains, plateaus, and such but it is not like Visio in that you can place things where you want them to go.

As for the rest - own them.  Tried them.  Not like Visio and rivers are just lines.  The nBoss program can be programmed like Visio but I decided to just go with Viso.

I will be out of the loop for a few days.  I have found a strange bug in jQuery and am trying to figure out what I want to do with that.  Not that this is a Visio problem - but what jQuery is doing is it will load up a web page onto a computer and then just....die.  There aren't any error messages and Javascript doesn't throw any error messages either.  It just - dies.  Firebug doesn't even show any code.  IE's debugger breaks on a "|" symbol that doesn't exist, and my other debuggers are just as baffled.  I switched all of my PHP/Javascript/HTML web pages over to jQuery and now I'm wondering if I made the wrong choice.  So I need to go look at this and find out just exactly what is going on.  It may take me as long as a week and as short as five minute.

My next step I was working on is to use a Polyline to show the fractal line that would be drawn.  In this way I can add/remove the line as the person drags their cursor from point A to point B.  Once the person lets go of the mouse, the Polyline is removed and the line segments are put in its place with the varying widths.  I should have it up and running by next week.
Title: Re: Change the size of a ink drawn line
Post by: markem on April 23, 2014, 04:55:12 PM
By the way - On the Campaign Cartographer's website forum I saw this really neat thing - Someone did signs for inns.  So I tried it in Visio.  Here are a couple of the signs I made.
Title: Re: Change the size of a ink drawn line
Post by: wapperdude on April 24, 2014, 08:26:31 PM
Those look nice!  Did you create custom wood grain backgrounds?

At the risk of being a pest, and you need not reply to this, did you look at Fractal Mapper?  The interface is not too bad, not as clean as Visio's, but is workable.  I've attached a sample that basically combines (subtracts) various fractal shapes.  The main is the land mass, then two smaller polygons were created and subtracted from the land mass.  Looks like the effect you're trying to achieve.  Anyway, this took about 5 minutes of effort.  Of course, it's not programmable, and, I haven't tried to import custom images.  The biggest drawback is generating very specific river shapes.

Wapperdude
Title: Re: Change the size of a ink drawn line
Post by: markem on April 25, 2014, 03:56:09 AM
That is similar to what I am trying to achieve.  I've got that program (and several others).  I'll have to go back and look at that again.  Thanks for posting it!  :-)

I look around on the internet for various wood layouts and found some fence ones I liked.  Then I imported the image into Visio, adjusted the wood so it was darker and looked more weather beaten.  Profantasy has thousands of images and the contract they used to give out (and may still do so) stated that you could use the images however you wanted.  So the bed, plate of food, empty plate, fork and spoon are all from there.  The lettering I did in Visio.  I decided to not modify the letters and make it semi-transparent because I wanted the letters to stick out.  The rest I made semi-transparent so the wood grain would show through.  I also overlaid the shield shape with a slightly smaller version that just had black and then changed the tansparency on that so it would also darken down the wood.  Then I put a line where the shield shape turned so they look like corners.  With this type of a layout I can adjust the wood to look more red or yellow or even painted.  I can also use Photoshop, Real Draw Pro, Painter, and other of the graphic programs I have to add various things.  If you have never looked at Real Draw Pro - you really should.  The program is by a guy in Russia and it does some amazing things.  It can act as a CAD program but the really neat thing about Real Draw Pro is that it can apply effects directly to a surface.  So you can start with a blank item, apply a wood-like effect to it - then overlay that with a slight metallic effect, do a 3D raised effect, and you suddenly have this terrific looking item.  Real Draw Pro also recognizes that in some pictures there is hidden height information so the darker areas become areas that are cut deeper into the surface of the object and it acts accordingly.  It is also a very fast program.  Everything I have ever done with it is done almost as quickly as I ask it to do it.  There is a slight pause - but not the five or ten minute kind of pause.  Just a second maybe.

Here is something I just finished last week.  It is called Centaur's Valley.  The players in my game are about to go out into the wide world.  Because my world is so deadly, everyone has to start off playing in a "safe" dungeon.  Once they are ready, they leave the dungeon and go out into the world.  This is an example of an area and how I set things up so I can ref the game.  This is why PowerPoint would also be a good option for me.  Because I can make various slides and annotate those slides as I go along.  Again - yet another reason to use Visio because you can copy between PowerPoint and Visio and if you left double-click an image in PowerPoint then Visio automatically comes up to let you modify everything.  :-)

One last reason to use Visio and PowerPoint - on tablets you can view PowerPoint presentations.  So if I take a tablet with me to the games I can show them the pages as needed.  Again, I hope to create a website where I can lay everything out as well as do the rivers, hills, and so forth.  But for now - I want to be able to create and then move the images over to PowerPoint.  I have to say though that PowerPoint 2003 can not even handle all of the images in the main map.  It says "Out of memory" when there is 1.8GB of memory available.  So for the main map - I do have to save it as a JPEG or PNG and the load it in to PowerPoint.  Sad really.  Short sightedness on the part of Microsoft.

Presently I am working on creating my own jQuery-like set of functions because I want to be able to go all the way back to Netscape Navigator v4.0.  I know a few people who still use that.  Seems weird I know - but what can I say?  Also, jQuery does not seem to work on some of my friend's computers.  Don't know why that is - their computers just won't do anything with jQuery.  And here I thought I had found the perfect thing to do javascript in.  :-/
Title: Re: Change the size of a ink drawn line
Post by: Jumpy on April 25, 2014, 07:24:43 AM
Quote from: markem on April 25, 2014, 03:56:09 AMThis is why PowerPoint would also be a good option for me.  Because I can make various slides and annotate those slides as I go along.

That remembers me of a project of mine that I work on in my spare time to get more familiar with Lazarus (at work I use Delphi).
It's a dungeon masters tool to present maps, pictures (for example of the monsters or end bosses), chapter intro's, background music, hexfield maps of rooms and dungeons with sprites on it to assist the imagination in fight situations (like classic table top games) and a assistant to manage the initiative of players and NPCs.
The idea is to use a beamer or monitor to assist the game session and maybe later on use it together with a team conference software to let players participate that can't be physically present because they live half a world away.

But it's still a work in progress, still playing arround with the database model because I want to make it very adaptive to many rule sets to assist in many typical RPGs and collecting ideas. Trying out different grafic engines. The real coding hasn't even started jet.
Title: Re: Change the size of a ink drawn line
Post by: markem on April 26, 2014, 06:45:54 PM
The main problem with PowerPoint (or rather a tablet's knock-off PowerPoint program) is that the graphics look terrible.  I just tried putting the Centaur's Valley into PowerPoint.  IN PowerPoint under Windows it looks terrific but on my tablet it is really bad.  Very jagged.  I used KingSoft's Office product and also Documents To Go.  Both just.....welll....I wouldn't call it THE ugliest thing in the world - but I would say "Can you say PacMan?" graphics.  So now I just saved...er....I could probably make it into a PDF....hmmmmm.....more later.  :-)
Title: Re: Change the size of a ink drawn line
Post by: markem on May 13, 2014, 01:07:07 AM
Ok first - a very BIG apology to Yacine and everyone else.  Because what Yacine posted did not look like what I was trying to achieve - I discounted what she was trying to say to me.  I sometimes get highly focused on my objectives and do not like to be dissuaded from them and my big objective was to learn how to program Visio. But what Yacine had said kept nagging at me like I had missed something important.

In my endeavors to make this all work I came full circle back to using a simple line pattern.  So I decided to try using Photoshop to create a river-like line pattern.  (See below)  Then I used the Freehand line to create a line and then applied the line pattern.  I then created a new pattern using the same effect to use for roads, and the edges of buildings so everything looked more like it was drawn by hand.  This DOES meet my expectations and it would not have been possible if Yacine hadn't first posted what she did.  So a very big thank you to Yacine and a smack up-side the head to me for being so myopic in my outlook.

But I am still learning more about programming Visio! :-)

By the way - the INK drawing tool causes there to be too many points and the line pattern becomes corrupted with a lot of spikes on the line.  So the freehand line tool has to be used instead.
Title: Re: Change the size of a ink drawn line
Post by: wapperdude on May 13, 2014, 03:33:32 AM
I'm sure Yacine will appreciate the comments.  HE'S good that way.  Seems, to be a common mistake...I know 1st hand!!!   :-[   I'm thinking of starting a club!   ::)   ???

Wapperdude
Title: Re: Change the size of a ink drawn line
Post by: markem on May 13, 2014, 04:54:47 AM
Oops!  Sorry Yacine!
Title: Re: Change the size of a ink drawn line
Post by: Yacine on May 13, 2014, 07:03:56 AM
No problem.
Glad you liked the line patterns.
Cheers,
Yacine (Yassin)
Title: Re: Change the size of a ink drawn line
Post by: vojo on May 14, 2014, 04:03:25 AM
for what its worth, I typcially do the following

user.size = width/ <predefined in mm width>
line = 2pt * user.size

if image grows, line gets thicker....if image shrinks, line gets thinner