CoCreate User Forum  

Go Back   CoCreate User Forum > Support > Customization

Reply
 
Thread Tools Search this Thread Rating: Thread Rating: 4 votes, 5.00 average. Display Modes
  #1  
Old 03-02-2011, 05:05 AM
rvn rvn is offline
Registered User
 
Join Date: Mar 2011
Posts: 52
lisp placing text

I've made a lisp file for placing a standard text.
But the first times it works fine, and the second time I have to restart modeling, so I think that it is hanging somewhere in my code. I think it is with the concatenate command. Can someone help me?

Thank you

(in-package :tekst)
(use-package :oli)



(sd-defdialog 'Tekst
:dialog-title "Tekst"
:persistent-proposals t
:variables '(
(RIEMTYPE :value-type :string
:initial-value "steekriem"
:proposals '("steekriem" "nokkenriem" "dubbele steekriem" "dubbele nokkenriem")
:auto-add-proposal t
:promt-text "Selecteer het type riem."
:title "Type riem")

(STAP :value-type :positive-number
:initial-value 28
:proposals '("28" "32" "35" "36" "40" "42" "44" "50" "56" "64" "72" "80" "88" "100")
:auto-add-proposal t
:promt-text "Selecteer de stap."
:title "Stap")

(AANTALRIEMEN :value-type :string
:initial-value "2"
:proposals '("2" "3" "4" "5")
:auto-add-proposal t
:promt-text "Selecteer het aantal riemen."
:title "Aantal riemen")

(RIEMBREEDTE :value-type :string
:initial-value "50"
:proposals '("50" "60" "60-30-60")
:auto-add-proposal t
:promt-text "Selecteer de riembreedte."
:title "Riembreedte")

(DIAMETER :value-type :string
:initial-value "<Diameter>8"
:proposals '("<Diameter>8" "<Diameter>9" "<Diameter>10" "<Diameter>11" "<Diameter>12" "<Diameter>14" "MA10" "MA11" "MA12" "MA14" "O-profiel" "H-profiel" "T5" "T6" "T7" "30x4-lijn" "30x4-verzet" "V10-lijn" "V10-verzet")
:auto-add-proposal t
:promt-text "Selecteer de spijldiameter."
:title "Spijldiameter")

(BEKLEDING :value-type :string
:initial-value "naakt"
:proposals '("naakt" "split-PVC <Diameter>10-14" "split-PVC <Diameter>11-16" "split-PVC <Diameter>8-12" "split-PVC <Diameter>9-12" "ster-PVC <Diameter>9.5-18" "ster-PVC <Diameter>10.5-16" "ster-PVC <Diameter>10.5-18" "ster-PVC <Diameter>11.5-18" "profiel T40-80" "profiel T50-100")
:auto-add-proposal t
:promt-text "Selecteer de bekleding."
:title "Bekleding")

(SLOT :value-type :string
:initial-value "slot"
:proposals '("slot" "versterkt slot" "dubbel slot" "dubbel slot h" "eindloos" "overlap")
:auto-add-proposal t
:promt-text "Selecteer de sluiting."
:title "Sluiting")

(RIVET :value-type :string
:initial-value "<Diameter>5"
:proposals '("<Diameter>5" "<Diameter>6")
:auto-add-proposal t
:promt-text "Selecteer de rivetdiameter."
:title "Rivetdiameter")

(LENGTE :value-type :positive-number
:promt-text "Geef de kettinglengte in."
:after-input (setf AANTALSPIJLEN (round (/ LENGTE STAP)))
:title "Lengte")

(BREEDTE :value-type :string
:promt-text "Geef de kettingbreedte in."
:after-input (doit)
:title "Breedte")

(PLAATS :value-type :docupntcnp
:title "Plaats")

(OWNER :selection (*sd-anno-sheet-seltype* *sd-anno-flat-seltype* *sd-anno-view-seltype* *sd-anno-sketch-seltype*)
:title "Owner"
:prompt-text "Duid de owner aan"
:after-input (sd-am-create-text :text TEKST
:position PLAATS
:owner_type :2dview
:owner OWNER)
)


(AANTALSPIJLEN :value-type :positive-integer
:initial-value 0
:promt-text "Geeft het aantal spijlen."
:title "Aantal spijlen")

) ;; end variables

:local-functions '(
(doit ()
(setf AANTS (sd-num-to-string AANTALSPIJLEN))
(setf LEN (sd-num-to-string LENGTE))
(setf ST (sd-num-to-string STAP))
(setf TEKST (concatenate 'string "breedte: " BREEDTE "mm" "
" "riemen: " AANTALRIEMEN "x " RIEMTYPE " stap " ST ", " SLOT "
" "spijlen: spijlen " DIAMETER " met " BEKLEDING "
" "rivetten: " RIVET "mm" "
" "omtreklengte: " AANTS " spijlen (" LEN "mm)"))
)
)

:ok-action '()

) ;; end dialog

Last edited by rvn; 03-11-2011 at 01:42 AM.
Reply With Quote
  #2  
Old 03-31-2011, 11:44 PM
Henk Stokkel Henk Stokkel is offline
Registered User
 
Join Date: Aug 2005
Location: Netherlands
Posts: 36
Re: lisp placing text

With me the macro works fine. I only had to change the title Tekst to Tekst1 and the dialog title to tekst1 because of a conflict with my macro's.
Reply With Quote
  #3  
Old 04-19-2011, 12:27 AM
rvn rvn is offline
Registered User
 
Join Date: Mar 2011
Posts: 52
Re: lisp placing text

Thanks Henk for trying. I tried it on another pc and it gives the same result. The first time it works fine and the second time modeling keeps showing the hourglass. Then I need to restart modeling. Is there somebody else who wants to try the lisp code? Or somebody who can help me with this problem?

thanks
Reply With Quote
  #4  
Old 04-19-2011, 06:58 AM
Andy Poulsen Andy Poulsen is offline
Administrator
 
Join Date: Apr 2003
Location: Fort Collins, Colorado
Posts: 273
Re: lisp placing text

Hi!

The first thing that jumps out to me is that at the end of your code, you're setting "tekst" to the concatenated string. Since the name of your dialog is also tekst, I believe you're overwriting the definition of your dialog code (which explains why it would work the first time, but not again).

I'm guessing that the reason you're setting the value of "tekst" to the concatenated string is to return that value when the command is called (which is the way it needs to be done in VB, I believe). Lisp doesn't require you to do it that way (and, in general, most CoCreate Modeling dialogs are not used to return values in that way, though they certainly can be).

What is more commonly done is to have the dialog set the value of a previously-defined variable that is then used as needed by your other functions, etc.

Does this make sense? I hope it helps!


EDIT:
After reviewing this again, I think that what you're wanting to do is just to change the name of the variable that you're using for the concatenated string. If you just change it to "tekst2" or something like that, you should be OK. If you're going to do that, though, you probably would want to make it a local variable (just changing it to "tekst2" would make tekst2 a global variable, which is not generally a good way to do things. Then the last part of your code (still in the variables section) could look something like this:
Code:
  (AANTALSPIJLEN :value-type :positive-integer
                                   :initial-value 0
                                   :prompt-text "Geeft het aantal spijlen."
                                   :title "Aantal spijlen")
   (TEKST2)  ;; define local variable here
     ) ;; end variables
 
 :local-functions
 '(
   (doit ()
    (setf AANTS (sd-num-to-string AANTALSPIJLEN))
    (setf LEN (sd-num-to-string LENGTE))
    (setf ST (sd-num-to-string STAP))
    (setf TEKST2 (concatenate 'string "breedte: " BREEDTE "mm" "
        " "riemen: " AANTALRIEMEN "x " RIEMTYPE " stap " ST ", " SLOT "
        " "spijlen: spijlen " DIAMETER " met " BEKLEDING "
        " "rivetten: " RIVET "mm" "
        " "omtreklengte: " AANTS " spijlen (" LEN "mm)"))
    )    
 )
 
 ) ;; end dialog
Or you can make the variable local only to the function:
Code:
  (AANTALSPIJLEN :value-type :positive-integer
                                    :initial-value 0
                                    :prompt-text "Geeft het aantal spijlen."
                                    :title "Aantal spijlen")
 ) ;; end variables
  
  :local-functions
  '(
   (doit ()
    (let (TEKST2)  ;; local variables only seen by this function
      (setf AANTS (sd-num-to-string AANTALSPIJLEN))
      (setf LEN (sd-num-to-string LENGTE))
      (setf ST (sd-num-to-string STAP))
      (setf TEKST2 (concatenate 'string "breedte: " BREEDTE "mm" "
           " "riemen: " AANTALRIEMEN "x " RIEMTYPE " stap " ST ", " SLOT "
           " "spijlen: spijlen " DIAMETER " met " BEKLEDING "
           " "rivetten: " RIVET "mm" "
           " "omtreklengte: " AANTS " spijlen (" LEN "mm)"))
      )
     )    
  )
  
  ) ;; end dialog
andy
__________________
Andy Poulsen
AI MAXTools: Dream. Design. Done. It's that easy!
Add-ins bringing new functionality and speed to Creo Elements/Direct and CoCreate products. Now available for v17-v20+!
See them in action at www.ai-maxtools.com and then try them for yourself -- FREE!

Last edited by Andy Poulsen; 04-19-2011 at 07:32 AM.
Reply With Quote
  #5  
Old 04-20-2011, 10:43 PM
rvn rvn is offline
Registered User
 
Join Date: Mar 2011
Posts: 52
Re: lisp placing text

Hi Andy,

Just changed the name of the variable and it works great for each time!
So many thanks for your help!!

Thanks and greetings
Ruben
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 04:37 PM.



Hosted by SureServer    Forums   Modeling FAQ   Macro Site   Vendor/Contractors   Software Resellers   CoCreate   Gallery   Home   Board Members   Regional User Groups  By-Laws  

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
You Rated this Thread: