1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Can you delete a sketch using script?

Discussion in 'Alibre Script' started by albie0803, Mar 11, 2020.

  1. albie0803

    albie0803 Alibre Super User

    When I use the sketch rotate command it creates a new sketch so the original one is now superfluous. Is there code to delete it?
     
  2. idslk

    idslk Alibre Super User

    Hello albie0803,
    what about
    upload_2020-3-11_8-48-7.png
    Regards
    Stefan
     
  3. albie0803

    albie0803 Alibre Super User

    Thank you. I must admit I only had a quick look before heading home.
     
  4. albie0803

    albie0803 Alibre Super User

    I have a question:

    S = Hub.AddSketch('KeyseatProfile-X', Hub.AddPlane('KeyseatPlane', F, 0))
    This defines sketch object S on plane "KeyseatPlane"

    Hub.RemoveSketch('KeyseatProfile-X')
    Removes the sketch
    BUT
    Hub.RemovePlane('KeyseatPlane')
    Won't remove the plane and throws an error

    KP = Hub.GetPlane('KeyseatPlane')
    Hub.RemovePlane(KP)

    removes the plane
    BUT
    I don't have to do this
    Hub.RemoveSketch(S)
    to remove the sketch

    I don't understand the logic ????? :confused::mad:
     
  5. NateLiqGrav

    NateLiqGrav Alibre Super User

    Not all methods are used the same and some methods are "Overloaded" meaning they have more than one possible way to use them.
    For example RemovePlane only can be used by passing it a Plane object. However RemoveSketch can be used by passing it a string of the sketch Name OR by passing it the sketch object directly. You should check the help file for what each one requires.

    upload_2020-3-19_19-11-40.png
     
    simonb65 likes this.
  6. NateLiqGrav

    NateLiqGrav Alibre Super User

    Also the word "void" in the above image is what that method expects to return. Void in this case means it doesn't return anything. Some methods do return values or objects. For example AddSketch returns a Sketch object.
     
  7. albie0803

    albie0803 Alibre Super User

    The reference guide is good if you understand python. For amateurs like me an example would make things so much easier.
    We have the "what", but not the "how" (to implement it).

    .RemoveSketch(String Name) I would interpret as 'Give the name of the sketch to be removed as a string'
    .RemovePlane (Plane Plane) really doesn't mean much
    .RemovePlane (Plane Descriptor) to me would be better. 'Give the descriptor of the plane object to be removed'

    A lot hinges on getting your head around the idea of python objects. Objects have a descriptor and may also have a nametag. They are not the same thing and sometimes you need to use the descriptor and other times the nametag.

    As I don't program very often, I end up with 'Oh yeah..thats right' moments after banging my head on the desk a few times. (or a lot of times and then pleading for help here)

    On a good note, today I was able to grab bits of an existing script, modify it and add a bit more and get what I wanted first go. Yay me!
     
  8. simonb65

    simonb65 Alibre Super User

    Python reference is pretty much how most programming languages are documented! The problem in this case is that the use of it and functions are specific to Alibre Design and so examples of each function would help 10 fold. Saying that, learning the basics of Python through the many available books and online resources would answer 50% of all questions that people struggle with when scripting in Alibre.

    If it makes you feel better, the examples of how to 'use' the Alibre API are sparse, outdated and do not give examples of how each function (or what those functions are) are non-existent. I've been writing code for 35+ years, but writing an Alibre Add-On was nothing short of a major challenge!
     
    Last edited: Mar 20, 2020

Share This Page