Jump to content

Script working as intended but errors are showing


Recommended Posts

import vs

NIEUW_SYMBOOL = "boom test symbool"   # <-- jouw doelsymbool

def is_dxf_symbool(naam):
    return (
        naam == "DXF point"
        or naam.startswith("symbolLayer")
    )

def verwerk_object(h):
    # 1. Kenmerken Door Klasse
    vs.SetPenColorByClass(h)
    vs.SetLWByClass(h)
    vs.SetLSByClass(h)
    vs.SetFillColorByClass(h)
    vs.SetFPatByClass(h)

    # 2. Alleen symbol-instances
    if vs.GetTypeN(h) == 15:  # symbol instance
        sym_naam = vs.GetSymName(h)

        if is_dxf_symbool(sym_naam):
            x, y = vs.GetSymLoc(h)
            rot = vs.GetSymRot(h)

            sx = vs.GetObjectVariableReal(h, 102)  # schaal X
            sy = vs.GetObjectVariableReal(h, 103)  # schaal Y

            klasse = vs.GetClass(h)
            laag = vs.GetLayer(h)

            vs.DelObject(h)

            nieuw = vs.Symbol(NIEUW_SYMBOOL, x, y)

            # correcte Python-manier
            vs.SetObjectVariableReal(nieuw, 1001, rot)
            vs.SetObjectVariableReal(nieuw, 102, sx)
            vs.SetObjectVariableReal(nieuw, 103, sy)

            vs.SetClass(nieuw, klasse)
            vs.SetLayer(nieuw, laag)

def main():
    vs.ForEachObject(verwerk_object, "ALL")
    vs.AlrtDialog(
        "Klaar: DXF point + symbolLayer-symbolen vervangen en alles Door Klasse gezet."
    )

main()

Hello fellow forum users,

 

With a lot of help from ChatGPT, i have 'made' this script. My programming knowledge is not zero but it is very limited. So far this script does exactly what i would like it to do. Although when running the script, I get the error message in the image. No suprise Chatgpt or Copilot have no clue why it is happening.

What is going wrong?

Schermafbeelding 2026-02-02 123139.png

Link to comment

Hello,

 

ChatGPT and other LLMs sometimes use vs. Functions that dont exist.

 

For example vs.SetLayer to my knowledge does Not exist. Use vs.SetParent instead. (Second Error)

 

The other Error is in the use of vs.Symbol. this function needs the name, the insertion coordinates an the insertion angle. You dont provide the angle.

 

Please search for the functions in the vwx function reference for more information.

 

Regards,

Letti

  • Like 2
Link to comment

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
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...