Main Menu

Recent posts

#1
General Visio / Re: A long list of shape data ...
Last post by Yacine - Today at 11:19:13 AM
And the jupyter notebook for the preparation magic.

# Too Many Props


```python
import xlwings as xw
```


```python
run vBase.ipynb
```

    Microsoft Visio
    TooManyProps_2024_05_07.vsdm
    Zeichenblatt-1
   


```python
filename = r'C:\Users\...\Documents\Visguy\TooManyProps\Props.xlsm' # insert the right path here.
```


```python
wb = xw.Book(filename)
```


```python
sht = wb.sheets[0]
data = sht.range('Table1').value
```


```python
data
```




    [[1.0, 'Base', 'personalID', 0.0, None],
     [2.0, 'Base', 'ForeName', 0.0, None],
     [3.0, 'Base', 'SecondName', 0.0, None],
     [4.0, 'Base', 'SurName', 0.0, None],
     [5.0, 'Base', 'BirtdDate', 5.0, None],
...




```python
shp = vWin.Selection(1)
```


```python
cats = []
for i in data:
    cat = i[1]
    if not cat in cats:
        cats.append(cat)
cats
```




    ['Base',
     'Address',
     'Contact',
     'Work',
     'HRL',
     'FacilityManagement',
     'Family',
     'Health',
     'Allergenes',
     'Medications',
     'OnCall']



### Collapsible Sub-sections


```python
cat_name = '___' + 'AllProps' + '___'
shp.AddNamedRow(visSectionProp, cat_name, visTagDefault)
shp.Cells('prop.' + cat_name + '.label').Formula = chr(34) + cat_name + chr(34)
shp.Cells('prop.' + cat_name + '.type').Formula = 1
shp.Cells('prop.' + cat_name + '.format').Formula = chr(34) + "INDIVIDUAL;TRUE;FALSE" + chr(34)
for cat in cats:
    cat_name = '___' + cat + '___'
    shp.AddNamedRow(visSectionProp, cat_name, visTagDefault)
    shp.Cells('prop.' + cat_name + '.label').Formula = chr(34) + cat_name + chr(34)
    shp.Cells('prop.' + cat_name + '.type').Formula = 3
    if cat == 'Base':
        shp.Cells('prop.' + cat_name).Formula = "TRUE"
        shp.Cells('prop.' + cat_name + '.invisible' ).Formula = "TRUE"
    cat_rows = [i for i in data if i[1] == cat]
    for row in cat_rows:
        prop = row[2]
        type_ = int(row[3])
        shp.AddNamedRow(visSectionProp, prop, visTagDefault)
        shp.Cells('prop.' + prop + '.label').Formula = chr(34) + prop + chr(34)
        shp.Cells('prop.' + prop + '.type').Formula = type_
        if type_ == 1:
            format_ = row[4]
            if format_:
                shp.Cells('prop.' + prop + '.format' ).Formula = chr(34) + format_ + chr(34)
        if cat != "Base":
            formula = 'IF(STRSAME(Prop.___AllProps___,"INDIVIDUAL"),NOT(Prop.' + cat_name + '),NOT(Prop.___AllProps___) )'
            #print(formula)
            shp.Cells('prop.' + prop + '.invisible' ).FormulaU = formula
   
```


```python
shp.DeleteSection(visSectionProp)
```

### Input form


```python
for cat in cats:
    cat_name = '___' + cat + '___'
    '''shp.AddNamedRow(visSectionProp, cat_name, visTagDefault)
    shp.Cells('prop.' + cat_name + '.label').Formula = chr(34) + cat_name + chr(34)
    shp.Cells('prop.' + cat_name + '.type').Formula = 3
    if cat == 'Base':
        shp.Cells('prop.' + cat_name).Formula = "TRUE"
        shp.Cells('prop.' + cat_name + '.invisible' ).Formula = "TRUE"
    '''
    cat_rows = [i for i in data if i[1] == cat]
    for row in cat_rows:
        prop = row[2]
        type_ = int(row[3])
        shp.AddNamedRow(visSectionProp, prop, visTagDefault)
        shp.Cells('prop.' + prop + '.label').Formula = chr(34) + prop + chr(34)
        shp.Cells('prop.' + prop + '.type').Formula = type_
        if type_ == 1:
            format_ = row[4]
            if format_:
                shp.Cells('prop.' + prop + '.format' ).Formula = chr(34) + format_ + chr(34)
    '''
        if cat != "Base":
            formula = 'IF(STRSAME(Prop.___AllProps___,"INDIVIDUAL"),NOT(Prop.' + cat_name + '),NOT(Prop.___AllProps___) )'
            #print(formula)
            shp.Cells('prop.' + prop + '.invisible' ).FormulaU = formula
    '''
```

### Sub-shapes as input



```python
shp.ConvertToGroup()
```


    ---------------------------------------------------------------------------

    com_error                                 Traceback (most recent call last)

    Cell In[51], line 1
    ----> 1 shp.ConvertToGroup()
   

    File D:\miniconda3\envs\YG1\Lib\site-packages\win32com\gen_py\00021A98-0000-0000-C000-000000000046x0x4x16\IVShape.py:155, in IVShape.ConvertToGroup(self)
        154 def ConvertToGroup(self):
    --> 155     return self._oleobj_.InvokeTypes(48, LCID, 1, (24, 0), (),)
   

    com_error: (-2147352567, 'Ausnahmefehler aufgetreten.', (0, 'Visio Professional', '\n\nRequested operation is presently disabled.', None, 0, -2032465766), None)



```python
previous_shp = None
for row in data:
    field = row[2]
    #print(field)
    fieldshp = shp.Drop(vDoc.Masters("Field"),1,1)
    try:
        fieldshp.NameU = field
    except:
        print("Error with :", field)
    fieldshp.Cells('user.invisible').Formula = "not(sheet." + str(shp.ID) + "!user.editmode)"
    if previous_shp:
        fieldshp.Cells('pinx').Formula = "sheet." + str(previous_shp.ID) + "!pinx"
        formula = "if(sheet." + str(shp.ID) + "!user.editmode; sheet." + str(previous_shp.ID) + "!piny - sheet." + str(previous_shp.ID) + "!height;0)"
        print(formula)
        fieldshp.Cells('piny').Formula = formula
    else:
        fieldshp.Cells('pinx').Formula = "sheet." + str(shp.ID) + "!controls.input"
        fieldshp.Cells('piny').Formula = "sheet." + str(shp.ID) + "!controls.input.y"
    previous_shp = fieldshp
previous_shp = None
```

    if(sheet.1!user.editmode; sheet.374!piny - sheet.374!height;0)
    if(sheet.1!user.editmode; sheet.376!piny - sheet.376!height;0)
...
   


```python
n = shp.Shapes.Count
for i in range(n,0,-1):
    shp.Shapes(i).Delete()
```


```python

```

#2
General Visio / Re: A long list of shape data ...
Last post by Yacine - Today at 11:18:02 AM
The subject inspired me. Have a look at the enclosed files.
They may give you some inspiration as well and maybe start a longer discussion.
#3
Right, now I can reproduce it as well.
It happens when you open the for file first time, like you said.
No idea how to fix. File a bug report to Microsoft?
#4
Visio Bugs (er...Issues) / Re: Visio 365 - Cannot link to...
Last post by Leines - Today at 09:56:38 AM
Quote from: Nikolay on May 01, 2024, 09:58:34 AMThe behavior does not seem to be reproducible (see the attached sample - VSDM - updates properly)

Could it be that some macro in the VSDM file prevents the formula from working?

that's exactly how my visio is set up. i also have this bug in your visio as soon as i use Visio365.
#5
Visio Bugs (er...Issues) / Re: Visio 365 - Cannot link to...
Last post by Leines - Today at 08:50:25 AM
Hello everyone,
Thank you very much for your answers.

I have inserted a Visio in the attachment.
Here on the first page is the shape, which I enter the values "Test" for example. This should now be transferred to the shapes on the other pages.
Unfortunately, this does not work with the VSDM, only when I enter the value again.
If you then close the file and open it again, it only works the second time you enter it.

There are currently no macros in the file, this is just a test file where I have only created one shape per page and stored the formula.

I have only renamed the first tab once. I am aware of the bug with multiple renaming. But it should not be the problem here.

#6
General Visio / Custom add-in on Mac via paral...
Last post by nickbarrett - Today at 04:04:22 AM
Anyone ever use the software "parallels" on a MAC and successfully run Visio with a custom addin? Trying to figure out if it is worth testing out.
#7
General Visio / Re: Connectors crossing over
Last post by wapperdude - May 06, 2024, 02:57:10 PM
The choice of line style contributes to the visual perception issue...that is, unfilled center.  Usually, a single solid version is less confusing to view.

By stowed, you mean vertically stacked, overlayed?  Some steps...
1) have all the ends terminate on same connection point
2) control the z-order of the shapes.  For example, the longest might be "sent to back", the shortest to the top / front.  This can be controlled by the order that they're drawn, and then, subsequently, by selecting each one.  https://learn.microsoft.com/en-us/office/client-developer/visio/displaylevel-cell-shape-layout-section

Yes.  Each connector may be added to a group to control its visibility.  Usually, layers define functionality / relationship as a means to hide/highlight related sets of objects.  See this video by Visio Guy, https://m.youtube.com/watch?v=xXRZ-Es37P0
#8
General Visio / Connectors crossing over
Last post by toko9811 - May 06, 2024, 02:26:47 PM
Dear friends,

I'm starting to draw wire harnesses in VISIO, but cant get the hang of the use of connectors.
Here is my problem:

For example: A harness with 3 ends.

The harness starts from the big block on top.
Running from the middle section down, it runs to 3 loose ends.
You cannot view this attachment.

How can i make these 3 ends make look ''stowed'' in the middle section.

As you can see the 3 ends do cross each other. Is it possible to give each end its own layer so they run over each other, instead of through each other.
#9
General Visio / Re: A long list of shape data ...
Last post by wapperdude - May 06, 2024, 02:00:01 PM
From my rocking chair musing, it seems to me that Visio isn't the best tool for handling such large amount of data entries.  It's hard to envision a scenario where a single shape would need such a large amount of data availability. 

The closest I've come would be some high pin count semiconductor device. Perhaps a programmable device where pin functionality might change.  My strategy would be to construct the shape via code...which has been done, but needs embellishment.  The embellishment would be to add Shapedata to each pin.  The shapedata, at least initially, is defined in Excel, where it could be structured into some meaningful, efficient arrangement.  Perhaps, introduce SETATREF() to allow direct shape updating to back flush into the data?  But, then, if this were a PGA device, I wouldn't be using Visio at all.

Well, need to refresh my cup of coffee...
#10
General Visio / Re: A long list of shape data ...
Last post by Visisthebest - May 06, 2024, 07:47:52 AM
No I mean users just editing the data not the definition of the shape data (in fact I disable shape data defining  in the end user file).

It's just very easy to see, quickly add say 30 string fields with the New button in define shape data, then when editing shape data you see the problem.