Re: __getattr__ Error

Mark Hammond <[email protected]> Mon, 18 Mar 2024 10:29:17 -0400
Newsgroups gmane.comp.python.windows
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--===============4043463277881636123==
Content-Type: multipart/alternative;
 boundary="------------0dePHwMxze1c0uVIFQtS45Hr"
Content-Language: en-US

This is a multi-part message in MIME format.
--------------0dePHwMxze1c0uVIFQtS45Hr
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

In general, if you `from win32com.client.gencache import 
EnsureDispatch`, you should be able to use `EnsureDispatch` anywhere you 
previously used plain `Dispatch`, and that code should be automatically 
generated and used for you. You generally only need to specify a special 
location or run makepy manually if there's something odd about the 
object which makes the above not work.

Mark

On 2024-03-18 10:25 a.m., Alok Bhargava wrote:
> Many thanks Harald!
>
> If I specify the file location when running makepy, how do I ensure 
> myapplication knows where to find them?  Again this may be a silly 
> question, so please bear with me.
>
> Thank you!
>
> On Mon, Mar 18, 2024 at 9:36 AM <[email protected]> wrote:
>
>     Hi Alok,
>
>     there should be a __gencache__ directory somewhere, which contains
>     the generated files.
>     But it is WAY easier to just use the
>
>       -o    -- Create output in a specified output file. If the path
>     leading
>                to the file does not exist, any missing directories will be
>                created.
>                NOTE: -o cannot be used with -d.  This will generate an
>     error.
>
>     parameter of makepy.py
>
>     cheers
>
>     Harald
>
>     On Mon, Mar 18, 2024 at 2:13 PM Alok Bhargava
>     <[email protected]> wrote:
>
>         Hi and thank you for your insightful guidance on Jannis'
>         question.  I am running into similar issues as I work with a
>         3rd party COM app.
>
>         This may be a silly question but could you point me to where
>         the generated class files are located?
>
>         Many thanks!
>
>
>         On Mon, Mar 18, 2024 at 7:43 AM <[email protected]>
>         wrote:
>
>             Hi Jannis,
>
>             a good way forward: create less-dynamic COM-bindings by
>             using makepy.py
>             (it is part of your win32com-client installation, but
>             linked here for the dokumentation)
>
>
>             https://github.com/SublimeText/Pywin32/blob/master/lib/x32/win32com/client/makepy.py
>
>             With makepy py you can create a (very very large)
>             python-file, which includes rather static bindings to
>             reachable exposed attributes and methods.
>
>             You can then grep or strg+f through that file for
>             "HybridShapes" ... maybe it is just spelled differently.
>
>             Using COM things for > 2 decades, apps run much smoother
>             using the makepy created files than dynamic dispatch
>
>             cheers
>
>             Harald
>
>
>             On Sun, Mar 17, 2024 at 7:35 PM Jannis via python-win32
>             <[email protected]> wrote:
>
>                 Hello together,
>
>
>                 I am trying to automate a point cloud creation out of
>                 CATParts in CATIA.
>                 The win32com client can access CATIA documents, but
>                 NOT methods and
>                 attributes in the parts. I get the following error:
>
>
>                 File
>                 "C:\Users\th80im\source\repos\PythonPointCloudCreation\PythonPointCloudCreation\PythonPointCloudCreation\py37_env_1\lib\site-packages\win32com\client\dynamic.py",
>                 line 638, in __getattr__
>                      raise AttributeError("%s.%s" % (self._username_,
>                 attr))
>                 AttributeError: <unknown>.HybridShapes
>
>
>                 I guess, there is something wrong with the registering
>                 of CATIA, or the
>                 installation of the client? Or am I looking in the
>                 wrong direction?
>
>
>                 Thank you & Best Regards
>
>                 ioannis
>
>                 _______________________________________________
>                 python-win32 mailing list
>                 [email protected]
>                 https://mail.python.org/mailman/listinfo/python-win32
>
>
>
>             -- 
>             -- 
>             Harald Armin Massa
>             Spielberger Straße 49
>             70435 Stuttgart
>             0173/9409607
>
>             _______________________________________________
>             python-win32 mailing list
>             [email protected]
>             https://mail.python.org/mailman/listinfo/python-win32
>
>
>
>     -- 
>     -- 
>     Harald Armin Massa
>     Spielberger Straße 49
>     70435 Stuttgart
>     0173/9409607
>
>
> _______________________________________________
> python-win32 mailing list
> [email protected]
> https://mail.python.org/mailman/listinfo/python-win32
--------------0dePHwMxze1c0uVIFQtS45Hr
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>In general, if you `from win32com.client.gencache import
      EnsureDispatch`, you should be able to use `EnsureDispatch`
      anywhere you previously used plain `Dispatch`, and that code
      should be automatically generated and used for you. You generally
      only need to specify a special location or run makepy manually if
      there's something odd about the object which makes the above not
      work.</p>
    <p>Mark<br>
    </p>
    <div class="moz-cite-prefix">On 2024-03-18 10:25 a.m., Alok Bhargava
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAN-Qc=dMyEJWNCmeDLOhedcv9hZMpDsTBwO=9MA9rPL1_knNrQ@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">
        <div>Many thanks Harald!</div>
        <div><br>
        </div>
        <div>If I specify the file location when running makepy, how do
          I ensure myapplication knows where to find them?  Again this
          may be a silly question, so please bear with me.</div>
        <div><br>
        </div>
        <div>Thank you!<br>
        </div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">On Mon, Mar 18, 2024 at
          9:36 AM &lt;<a href="mailto:[email protected]"
            moz-do-not-send="true" class="moz-txt-link-freetext">[email protected]</a>&gt;
          wrote:<br>
        </div>
        <blockquote class="gmail_quote"
style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
          <div dir="ltr">Hi Alok,
            <div><br>
            </div>
            <div>there should be a __gencache__ directory somewhere,
              which contains the generated files.</div>
            <div>But it is WAY easier to just use the</div>
            <div><br>
            </div>
            <div>  -o    -- Create output in a specified output file. 
              If the path leading<br>
                         to the file does not exist, any missing
              directories will be<br>
                         created.<br>
                         NOTE: -o cannot be used with -d.  This will
              generate an error.<br>
            </div>
            <div><br>
            </div>
            <div>parameter of makepy.py</div>
            <div><br>
            </div>
            <div>cheers</div>
            <div><br>
            </div>
            <div>Harald</div>
          </div>
          <br>
          <div class="gmail_quote">
            <div dir="ltr" class="gmail_attr">On Mon, Mar 18, 2024 at
              2:13 PM Alok Bhargava &lt;<a
                href="mailto:[email protected]" target="_blank"
                moz-do-not-send="true" class="moz-txt-link-freetext">[email protected]</a>&gt;
              wrote:<br>
            </div>
            <blockquote class="gmail_quote"
style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
              <div dir="ltr">
                <div>Hi and thank you for your insightful guidance on
                  Jannis' question.  I am running into similar issues as
                  I work with a 3rd party COM app.</div>
                <div><br>
                </div>
                <div>This may be a silly question but could you point me
                  to where the generated class files are located?</div>
                <div><br>
                </div>
                <div>Many thanks!</div>
                <div><br>
                </div>
              </div>
              <br>
              <div class="gmail_quote">
                <div dir="ltr" class="gmail_attr">On Mon, Mar 18, 2024
                  at 7:43 AM &lt;<a
                    href="mailto:[email protected]"
                    target="_blank" moz-do-not-send="true"
                    class="moz-txt-link-freetext">[email protected]</a>&gt;
                  wrote:<br>
                </div>
                <blockquote class="gmail_quote"
style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
                  <div dir="ltr">Hi Jannis,
                    <div><br>
                    </div>
                    <div>a good way forward: create less-dynamic
                      COM-bindings by using makepy.py </div>
                    <div>(it is part of your win32com-client
                      installation, but linked here for the
                      dokumentation)</div>
                    <div><br>
                    </div>
                    <div><br>
                    </div>
                    <div><a
href="https://github.com/SublimeText/Pywin32/blob/master/lib/x32/win32com/client/makepy.py"
                        target="_blank" moz-do-not-send="true"
                        class="moz-txt-link-freetext">https://github.com/SublimeText/Pywin32/blob/master/lib/x32/win32com/client/makepy.py</a><br>
                    </div>
                    <div><br>
                    </div>
                    <div>With makepy py you can create a (very very
                      large) python-file, which includes rather static
                      bindings to</div>
                    <div>reachable exposed attributes and methods.</div>
                    <div><br>
                    </div>
                    <div>You can then grep or strg+f through that file
                      for "HybridShapes" ... maybe it is just spelled
                      differently.</div>
                    <div><br>
                    </div>
                    <div>Using COM things for &gt; 2 decades, apps run
                      much smoother using the makepy created files than
                      dynamic dispatch</div>
                    <div><br>
                    </div>
                    <div>cheers</div>
                    <div><br>
                    </div>
                    <div>Harald</div>
                    <div><br>
                    </div>
                  </div>
                  <br>
                  <div class="gmail_quote">
                    <div dir="ltr" class="gmail_attr">On Sun, Mar 17,
                      2024 at 7:35 PM Jannis via python-win32 &lt;<a
                        href="mailto:[email protected]"
                        target="_blank" moz-do-not-send="true"
                        class="moz-txt-link-freetext">[email protected]</a>&gt;
                      wrote:<br>
                    </div>
                    <blockquote class="gmail_quote"
style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello
                      together,<br>
                      <br>
                      <br>
                      I am trying to automate a point cloud creation out
                      of CATParts in CATIA.<br>
                      The win32com client can access CATIA documents,
                      but NOT methods and<br>
                      attributes in the parts. I get the following
                      error:<br>
                      <br>
                      <br>
                      File<br>
"C:\Users\th80im\source\repos\PythonPointCloudCreation\PythonPointCloudCreation\PythonPointCloudCreation\py37_env_1\lib\site-packages\win32com\client\dynamic.py",<br>
                      line 638, in __getattr__<br>
                           raise AttributeError("%s.%s" %
                      (self._username_, attr))<br>
                      AttributeError: &lt;unknown&gt;.HybridShapes<br>
                      <br>
                      <br>
                      I guess, there is something wrong with the
                      registering of CATIA, or the<br>
                      installation of the client? Or am I looking in the
                      wrong direction?<br>
                      <br>
                      <br>
                      Thank you &amp; Best Regards<br>
                      <br>
                      ioannis<br>
                      <br>
                      _______________________________________________<br>
                      python-win32 mailing list<br>
                      <a href="mailto:[email protected]"
                        target="_blank" moz-do-not-send="true"
                        class="moz-txt-link-freetext">[email protected]</a><br>
                      <a
href="https://mail.python.org/mailman/listinfo/python-win32"
                        rel="noreferrer" target="_blank"
                        moz-do-not-send="true"
                        class="moz-txt-link-freetext">https://mail.python.org/mailman/listinfo/python-win32</a><br>
                    </blockquote>
                  </div>
                  <br clear="all">
                  <div><br>
                  </div>
                  <span class="gmail_signature_prefix">-- </span><br>
                  <div dir="ltr" class="gmail_signature">
                    <div dir="ltr">--
                      <div>Harald Armin Massa<br>
                        Spielberger Straße 49<br>
                        70435 Stuttgart<br>
                        0173/9409607<br>
                        <br>
                      </div>
                    </div>
                  </div>
                  _______________________________________________<br>
                  python-win32 mailing list<br>
                  <a href="mailto:[email protected]"
                    target="_blank" moz-do-not-send="true"
                    class="moz-txt-link-freetext">[email protected]</a><br>
                  <a
href="https://mail.python.org/mailman/listinfo/python-win32"
                    rel="noreferrer" target="_blank"
                    moz-do-not-send="true" class="moz-txt-link-freetext">https://mail.python.org/mailman/listinfo/python-win32</a><br>
                </blockquote>
              </div>
            </blockquote>
          </div>
          <br clear="all">
          <div><br>
          </div>
          <span class="gmail_signature_prefix">-- </span><br>
          <div dir="ltr" class="gmail_signature">
            <div dir="ltr">--
              <div>Harald Armin Massa<br>
                Spielberger Straße 49<br>
                70435 Stuttgart<br>
                0173/9409607<br>
                <br>
              </div>
            </div>
          </div>
        </blockquote>
      </div>
      <br>
      <fieldset class="moz-mime-attachment-header"></fieldset>
      <pre wrap="" class="moz-quote-pre">_______________________________________________
python-win32 mailing list
<a class="moz-txt-link-abbreviated" href="mailto:[email protected]">[email protected]</a>
<a class="moz-txt-link-freetext" href="https://mail.python.org/mailman/listinfo/python-win32">https://mail.python.org/mailman/listinfo/python-win32</a>
</pre>
    </blockquote>
  </body>
</html>

--------------0dePHwMxze1c0uVIFQtS45Hr--

--===============4043463277881636123==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
python-win32 mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-win32

--===============4043463277881636123==--