Home > Community > Forums > Custom IC SKILL > Passing values through a Skill User Form

Email

* Required Fields

Recipients email * (separate multiple addresses with commas)

Your name *

Your email *

Message *

Contact Us

* Required Fields
First Name *

Last Name *

Email *

Company / Institution *

Comments: *

 Passing values through a Skill User Form 

Last post Mon, Mar 4 2013 8:56 PM by NKU10k. 4 replies.
Started by NKU10k 02 Mar 2013 07:16 AM. Topic has 4 replies and 1023 views
Page 1 of 1 (5 items)
Sort Posts:
  • Sat, Mar 2 2013 7:16 AM

    • NKU10k
    • Not Ranked
    • Joined on Sat, Mar 2 2013
    • Posts 7
    • Points 125
    Passing values through a Skill User Form Reply

     Hi,

    I am trying to create a form accesible with a menu in Virtuoso Layout editor to create a complex shape. Managed to add the menu, couple of menu items and create a form using material in this forum and web but struggling to pass the values input through the form to a procedure. I am trying to draw a donutas a start.

    My code is copied below and appriciate anyone can help figuring out the problem.

    The error  message is

    *Error* dbCreateDonut argument #4 should be a number (type template = "dglnn") - nil

    procedure(CreateAddDoForm()
         let((InnerRadius OuterRadius Centre Layer)
            InnerRadius=hiCreateIntField(
                    ?name 'InnerRadius
                    ?prompt "Inner Radius"
                    )
        OuterRadius=hiCreateIntField(
                    ?name 'OuterRadius
                    ?prompt "Outer Radius"
                    )
        Centre=hiCreateIntField(
                    ?name 'Centre
                    ?prompt "Centre"
                    )
            Layer=hiCreateIntField(
                    ?name 'Layer
                    ?prompt "Layer"
                    )
                   
            hiCreateAppForm(
                ?name 'AddDonutForm
                ?formTitle "Input Source Parameters"
                ?buttonLayout 'OKCancelApply
                ?callback "DrawDonut()"
                ?fields
                    list(
                        list(InnerRadius 0:0 200:30 100)
                        list(OuterRadius 0:35 200:30 100)
                        list(Centre 0:70 200:30 100)
                        list(Layer 0:105 200:30 100)
                        )
                          )
             );let
          );procedure

    procedure(FunctionAddDonut()
         unless(boundp('AddDonutForm)
            CreateAddDoForm()
               )
      
         hiDisplayForm(AddDonutForm)
             )

    procedure(DrawDonut()
          let( (Orad Irad)
            Orad=AddDonutForm->OuterRadius->Value
            Irad=AddDonutForm->InnerRadius->Value
            cvID=geGetWindowCellView()
            dbCreateDonut(cvID "DIFF"  0:0 Orad Irad)
           
           )

          )

     

    • Post Points: 20
  • Mon, Mar 4 2013 1:54 AM

    Re: Passing values through a Skill User Form Reply

    In your DrawDonut function, the ->Value should be ->value (it is case sensitive):

     procedure(DrawDonut()
          let( (Orad Irad)
            Orad=AddDonutForm->OuterRadius->value
            Irad=AddDonutForm->InnerRadius->value
            cvID=geGetWindowCellView()
            dbCreateDonut(cvID "Metal2"  0:0 Orad Irad)
           
           )

          )

    Regards,

    Andrew.

    • Post Points: 20
  • Mon, Mar 4 2013 6:42 AM

    • NKU10k
    • Not Ranked
    • Joined on Sat, Mar 2 2013
    • Posts 7
    • Points 125
    Re: Passing values through a Skill User Form Reply

     Superb Andrew! Many thanks.

    Can I ask one more question please....

    I am trying to chop a donut into peices with leChopShape so that I can remove pieces of the donut. In the following code I wrote, it works for couple of i s and doesn't do it all the way around the donut. 

    I checked whether the logic is working with the commented out dbCreateLine statement which seem to draw the line as I want it.

    I was wondering whether the db ID of the shape is changed when it is chopped and tried get the handle with  "NewShapes" but didn't quite work.

    Appriciate of you can help.

    Try the ConstructCog(100 2 1 1 2) to invoke it.

    Many thanks again.

     

    procedure( ConstructCog(cc_mainR cc_SourceNLength cc_NPolyOvelap cc_NWidth cc_PWidth)

         MainCirc= 2*3.14*cc_mainR
        NumOfSegs=round(MainCirc/(cc_NWidth+cc_PWidth))
        SegWidth=MainCirc/NumOfSegs
        SegNWidth=SegWidth*cc_NWidth/(cc_NWidth+cc_PWidth)
       
        cc_InnerR=cc_mainR-cc_NPolyOvelap
        cc_OuterR=cc_mainR+cc_SourceNLength
           
        cvID=geGetWindowCellView()
        donutID=dbCreateDonut(cvID "NPLUS"  0:0  cc_OuterR cc_InnerR)
        ;hiZoomAbsoluteScale(cvID 1) ; want to zoom to fit, doesn't work

        NSegAngle=SegNWidth/cc_mainR
        PitchAngle=SegWidth/cc_mainR
        cc_TempRadius=cc_mainR+cc_SourceNLength+1

    for(i 1 NumOfSegs

        i_FirstX=cc_TempRadius*cos((i-1)*PitchAngle)
        i_FirstY=cc_TempRadius*sin((i-1)*PitchAngle)
        i_secondX=cc_TempRadius*cos((i-1)*PitchAngle+NSegAngle)
        i_secondY=cc_TempRadius*sin((i-1)*PitchAngle+NSegAngle)
       
        ;dbCreateLine(cvID "PPLUS" list(0:0 i_FirstX:i_FirstY i_secondX:i_secondY 0:0))
       

        ;leChopShape( donutID list(0:0 i_FirstX:i_FirstY i_secondX:i_secondY 0:0) nil nil 300 )

        NewShapes=leChopShape( donutID list(0:0 i_FirstX:i_FirstY i_secondX:i_secondY 0:0)
        nil nil 300 )
        donutID=cadr(NewShapes)
       
        );for
          ) ;procedure
     

     

     

    • Post Points: 20
  • Mon, Mar 4 2013 7:15 AM

    Re: Passing values through a Skill User Form Reply

    The problem is that leChopShape will return a list of the new shapes - and you have no idea which is the one you want to do subsequent chops on. Now you're not removing the gaps you're chopping out (I suspect you want to though) - but even if you do that, it's not going to solve the problem - fundamentally you will end up with two or three shapes when you chop the remainder of the donut (depending on whether you keep the shapes in the chopped region). If you pick the wrong shape (you have arbitrarily chosen then cadr), then the next chop will return nil because there was nothing that was chopped.

    So I think you need to do something like the below - use dbGetTrueOverlaps to find the polygon underneath the mid point of the next segment to be chopped (I compute the midRadius and then a point half way through that segment) - and then chop that. In this example I also remove the chopped region (you must tell it that the chop points are a closed polygon for that to work) - whether you want to do that or not is up to you (this is the t t arguments in leChopShape).

    I also added local variables too, for good measure. Note that in the code, you might be able to use cc_mainR rather than computing cc_midRadius (I'll leave that to you - I only spotted this upon reviewing the code).

    Regards,

    Andrew.

    procedure( ConstructCog(cc_mainR cc_SourceNLength cc_NPolyOvelap cc_NWidth cc_PWidth)

      let((MainCirc NumOfSegs SegWidth SegNWidth cc_InnerR cc_OuterR cvID donutID NSegAngle
        PitchAngle cc_TempRadius cc_midRadius i_FirstX i_FirstY i_secondX i_secondY
        identifyX identifyY NewShapes)

         MainCirc= 2*3.14*cc_mainR
        NumOfSegs=round(MainCirc/(cc_NWidth+cc_PWidth))
        SegWidth=MainCirc/NumOfSegs
        SegNWidth=SegWidth*cc_NWidth/(cc_NWidth+cc_PWidth)
      
        cc_InnerR=cc_mainR-cc_NPolyOvelap
        cc_OuterR=cc_mainR+cc_SourceNLength
          
        cvID=geGetWindowCellView()
        donutID=dbCreateDonut(cvID "Metal2"  0:0  cc_OuterR cc_InnerR)
        ;hiZoomAbsoluteScale(cvID 1) ; want to zoom to fit, doesn't work

        NSegAngle=SegNWidth/cc_mainR
        PitchAngle=SegWidth/cc_mainR
        cc_TempRadius=cc_mainR+cc_SourceNLength+1

        cc_midRadius=(cc_OuterR+cc_InnerR)/2.0

        for(i 1 NumOfSegs

            i_FirstX=cc_TempRadius*cos((i-1)*PitchAngle)
            i_FirstY=cc_TempRadius*sin((i-1)*PitchAngle)
            i_secondX=cc_TempRadius*cos((i-1)*PitchAngle+NSegAngle)
            i_secondY=cc_TempRadius*sin((i-1)*PitchAngle+NSegAngle)

            identifyX=cc_midRadius*cos((i-1)*PitchAngle+NSegAngle/2.0)
            identifyY=cc_midRadius*sin((i-1)*PitchAngle+NSegAngle/2.0)
            donutID=car(dbGetTrueOverlaps(cvID list(identifyX:identifyY identifyX:identifyY) "Metal2" 0))
          
            ;dbCreateLine(cvID "PPLUS" list(0:0 i_FirstX:i_FirstY i_secondX:i_secondY 0:0))
          

            ;leChopShape( donutID list(0:0 i_FirstX:i_FirstY i_secondX:i_secondY 0:0) nil nil 300 )

            NewShapes=leChopShape( donutID list(0:0 i_FirstX:i_FirstY i_secondX:i_secondY 0:0)
            t t 300 )
        ;    donutID=car(NewShapes)
          
        );for
      )
    ) ;procedure
    • Post Points: 20
  • Mon, Mar 4 2013 8:56 PM

    • NKU10k
    • Not Ranked
    • Joined on Sat, Mar 2 2013
    • Posts 7
    • Points 125
    Re: Passing values through a Skill User Form Reply

     Thanks Andrew. This is very very helpful.

    Will save days!!

     

     

    • Post Points: 5
Page 1 of 1 (5 items)
Sort Posts:
Started by NKU10k at 02 Mar 2013 07:16 AM. Topic has 4 replies.