Hot News:

Mit Unterstützung durch:

  Foren auf CAD.de (alle Foren)
  PTC Creo Elements/Programmierung
  How to load standard parts from part library via lisp?

Antwort erstellen  Neues Thema erstellen
CAD.de Login | Logout | Profil | Profil bearbeiten | Registrieren | Voreinstellungen | Hilfe | Suchen

Anzeige:

Darstellung des Themas zum Ausdrucken. Bitte dann die Druckfunktion des Browsers verwenden. | Suche nach Beiträgen nächster neuer Beitrag | nächster älterer Beitrag
  
Gut zu wissen: Hilfreiche Tipps und Tricks aus der Praxis prägnant, und auf den Punkt gebracht für PTC CREO
Autor Thema:  How to load standard parts from part library via lisp? (1019 mal gelesen)
Andylau
Mitglied



Sehen Sie sich das Profil von Andylau an!   Senden Sie eine Private Message an Andylau  Schreiben Sie einen Gästebucheintrag für Andylau

Beiträge: 55
Registriert: 07.06.2021

erstellt am: 08. Okt. 2021 09:39    Editieren oder löschen Sie diesen Beitrag!  <-- editieren / zitieren -->   Antwort mit Zitat in Fett Antwort mit kursivem Zitat    Unities abgeben: 1 Unity (wenig hilfreich, aber dennoch)2 Unities3 Unities4 Unities5 Unities6 Unities7 Unities8 Unities9 Unities10 Unities


3.jpg

 
I wanted to load a screw (din558 M5x20) to a hole.

I used recorder, and got codes below:

Code:

preselect
ts-catalog-laden-dialog :neu :on
"PARAMETER"
"normteile/schrauben/sechskantschrauben/din_558"
"0000000000"
" 'NAME_ORIG' 'DN' 'A' 'C' 'DW' 'K' 'R' 'S' 'L' 'PNR' 'SID' 'DESCRIPTION_ORIG' 'NAME' 'BEZEICHNUNG' 'THREAD' 'THREAD_TYPE' 'DELETE' 'FAVORITE'"
" 'Schraube_M_5x20_DIN_558' '5' '3.2' '0' '0' '3.5' '0.2' '8' '20' '' 'din558_5_20' 'Sechskantschraube DIN 558-M5x20' 'Screw_DIN_558-M5x20' 'Hexagon head screw DIN 558-M5x20' 'M5' 'metrisch' '' ''"

" "
" "
(gpntwc 47.904477 33.218079 1.244108 "vport1")
complete
preselect



with this code input in the command line, I can load the screw.

But with the code in the lisp, it didn't work.

Code:

(ts-catalog-laden-dialog :neu :on
"PARAMETER"
"normteile/schrauben/sechskantschrauben/din_558"
"0000000000"
" 'NAME_ORIG' 'DN' 'A' 'C' 'DW' 'K' 'R' 'S' 'L' 'PNR' 'SID' 'DESCRIPTION_ORIG' 'NAME' 'BEZEICHNUNG' 'THREAD' 'THREAD_TYPE' 'DELETE' 'FAVORITE'"
" 'Schraube_M_5x20_DIN_558' '5' '3.2' '0' '0' '3.5' '0.2' '8' '20' '' 'din558_5_20' 'Sechskantschraube DIN 558-M5x20' 'Screw_DIN_558-M5x20' 'Hexagon head screw DIN 558-M5x20' 'M5' 'metrisch' '' ''"
" "
" "
;(gpntwc 47.904477 33.218079 1.244108 "vport1")
a_circle_edge ;some circle edge
)

So how to load the screw correctly in lisp?

Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP

Andylau
Mitglied



Sehen Sie sich das Profil von Andylau an!   Senden Sie eine Private Message an Andylau  Schreiben Sie einen Gästebucheintrag für Andylau

Beiträge: 55
Registriert: 07.06.2021

erstellt am: 08. Okt. 2021 10:02    Editieren oder löschen Sie diesen Beitrag!  <-- editieren / zitieren -->   Antwort mit Zitat in Fett Antwort mit kursivem Zitat    Unities abgeben: 1 Unity (wenig hilfreich, aber dennoch)2 Unities3 Unities4 Unities5 Unities6 Unities7 Unities8 Unities9 Unities10 Unities


testcode.lsp.txt

 
My test code is attached.

Thanks in advance.

Andy

Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP

Andylau
Mitglied



Sehen Sie sich das Profil von Andylau an!   Senden Sie eine Private Message an Andylau  Schreiben Sie einen Gästebucheintrag für Andylau

Beiträge: 55
Registriert: 07.06.2021

erstellt am: 08. Okt. 2021 14:23    Editieren oder löschen Sie diesen Beitrag!  <-- editieren / zitieren -->   Antwort mit Zitat in Fett Antwort mit kursivem Zitat    Unities abgeben: 1 Unity (wenig hilfreich, aber dennoch)2 Unities3 Unities4 Unities5 Unities6 Unities7 Unities8 Unities9 Unities10 Unities

If I input the code to command line with parentheses.
Then the code didn't work.

Usually, when I got a command from the recorder, and input them to command line with parentheses, they should work.
But this command "ts-catalog-laden-dialog" was so different.

Code:

(ts-catalog-laden-dialog :neu :on
"PARAMETER"
"normteile/schrauben/sechskantschrauben/din_558"
"0000000000"
" 'NAME_ORIG' 'DN' 'A' 'C' 'DW' 'K' 'R' 'S' 'L' 'PNR' 'SID' 'DESCRIPTION_ORIG' 'NAME' 'BEZEICHNUNG' 'THREAD' 'THREAD_TYPE' 'DELETE' 'FAVORITE'"
" 'Schraube_M_5x20_DIN_558' '5' '3.2' '0' '0' '3.5' '0.2' '8' '20' '' 'din558_5_20' 'Sechskantschraube DIN 558-M5x20' 'Screw_DIN_558-M5x20' 'Hexagon head screw DIN 558-M5x20' 'M5' 'metrisch' '' ''"
" "
" "
(gpntwc 47.904477 33.218079 1.244108 "vport1")
complete)

Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP

Andylau
Mitglied



Sehen Sie sich das Profil von Andylau an!   Senden Sie eine Private Message an Andylau  Schreiben Sie einen Gästebucheintrag für Andylau

Beiträge: 55
Registriert: 07.06.2021

erstellt am: 10. Okt. 2021 05:20    Editieren oder löschen Sie diesen Beitrag!  <-- editieren / zitieren -->   Antwort mit Zitat in Fett Antwort mit kursivem Zitat    Unities abgeben: 1 Unity (wenig hilfreich, aber dennoch)2 Unities3 Unities4 Unities5 Unities6 Unities7 Unities8 Unities9 Unities10 Unities

I find it at last.

use sd-put-buffer

Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP

Andylau
Mitglied



Sehen Sie sich das Profil von Andylau an!   Senden Sie eine Private Message an Andylau  Schreiben Sie einen Gästebucheintrag für Andylau

Beiträge: 55
Registriert: 07.06.2021

erstellt am: 13. Okt. 2021 06:23    Editieren oder löschen Sie diesen Beitrag!  <-- editieren / zitieren -->   Antwort mit Zitat in Fett Antwort mit kursivem Zitat    Unities abgeben: 1 Unity (wenig hilfreich, aber dennoch)2 Unities3 Unities4 Unities5 Unities6 Unities7 Unities8 Unities9 Unities10 Unities


testcode2.lsp

 
After the loading of standard part, I still had some problem for getting the pathname of this new loaded part.
I used traverse method to get all the pathnames in drawlist after the loading, but couldnt' find the new part.
Code:


(use-package :OLI)

(sd-defdialog 'testcode
:dialog-title (sd-multi-lang-string "testcode" :schinese "testcode")
:toolbox-button t
:variables '(

)

:local-functions
'(
(doit ()


(setf parts_before (jb-inq-obj-tree-list (sd-pathname-to-obj "/")))
(setf parts_before
(remove-if
#'(lambda (obj)
(not (equal (sel_item-type obj) *sd-part-seltype*)))
parts_before))

(sd-put-buffer
"
ts-catalog-laden-dialog :neu :on
\"PARAMETER\"
\"normteile/scheiben/din_125a\"
\"0000000000\"
\" 'NAME_ORIG' 'DN' 'H' 'DI' 'DA' 'PNR' 'SID' 'DESCRIPTION_ORIG' 'NAME' 'BEZEICHNUNG' 'DELETE' 'FAVORITE'\"
\" 'Scheibe_A_10_5_DIN_125' '10' '2' '10.5' '20' '' 'din125a_10_2_10.5_20' 'Scheibe DIN 125 - A10.5' 'Washer_DIN_125-A10.5' 'Washer DIN 125 - A10.5' '' ''\"
\" \"
\" \"
(gpntwc 0 0 0 \"vport1\")
complete
"
)


(setf parts_after (jb-inq-obj-tree-list (sd-pathname-to-obj "/")))
(setf parts_after (remove-if #'(lambda (obj)
(not (equal (sel_item-type obj) *sd-part-seltype*))) parts_after)
)

;(display parts_after)

(dolist (part parts_after)
(display (sd-inq-obj-pathname part))
)
(display "------------")




)


(jb-inq-obj-tree-list (obj)
(cons obj
(apply #'nconc (mapcar #'jb-inq-obj-tree-list (sd-inq-obj-children obj)))
)
)

)
:ok-action
'(doit)

)


Anyone who knows why?

Best regards,
Andy

Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP

Andylau
Mitglied



Sehen Sie sich das Profil von Andylau an!   Senden Sie eine Private Message an Andylau  Schreiben Sie einen Gästebucheintrag für Andylau

Beiträge: 55
Registriert: 07.06.2021

erstellt am: 13. Okt. 2021 16:37    Editieren oder löschen Sie diesen Beitrag!  <-- editieren / zitieren -->   Antwort mit Zitat in Fett Antwort mit kursivem Zitat    Unities abgeben: 1 Unity (wenig hilfreich, aber dennoch)2 Unities3 Unities4 Unities5 Unities6 Unities7 Unities8 Unities9 Unities10 Unities

Use this? But How?

*SD-CHANGE-OBJECT-TREE-EVENT*
Processed when a new object is created
Processed when an object is deleted
Processed when an object relationship changes

Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP

AlexG
Mitglied



Sehen Sie sich das Profil von AlexG an!   Senden Sie eine Private Message an AlexG  Schreiben Sie einen Gästebucheintrag für AlexG

Beiträge: 132
Registriert: 05.04.2013

CP/M; 6510@0,985249 MHz; 64KB RAM; 20KB ROM; MOS 6569

erstellt am: 14. Okt. 2021 17:03    Editieren oder löschen Sie diesen Beitrag!  <-- editieren / zitieren -->   Antwort mit Zitat in Fett Antwort mit kursivem Zitat    Unities abgeben: 1 Unity (wenig hilfreich, aber dennoch)2 Unities3 Unities4 Unities5 Unities6 Unities7 Unities8 Unities9 Unities10 Unities Nur für Andylau 10 Unities + Antwort hilfreich

Hi Andy,

Unfortunately, since I can't test the code, I can only make guesses. Maybe it helps to determine the result of the two lists parts_before and parts_after by means of SET-DIFFERENCE http://clhs.lisp.se/Body/f_set_di.htm. This has worked well for me in the past.

Anyhow to provide somehow more information on events. They should work like this:

Code:

(defun event-test-function (arg &rest more-args)
  "Just a dummy function. This function is called when the event gets triggered."
  (display (format nil "Event was triggered with argument '~a'~@[ and even more arguments '~a'~]" arg more-args)))

;; Subscribe event
(oli:sd-subscribe-event oli:*sd-change-object-tree-event* 'event-test-function "Some arguments")


(Manually) triggere event. Event *sd-change-object-tree-event* also is fired if something has changed in the object tree/browser view:

Code:
(oli:sd-process-event oli:*sd-change-object-tree-event* 42 '("the" "answer" "is"))

Additional information. To unsubscribe event use:

Code:
(oli:sd-unsubscribe-event oli:*sd-change-object-tree-event* 'event-test-function)

For even more detailed information refere to http://www.clausbrod.de/cgi-bin/view.pl/CoCreateModeling/MacroAlarmClock

I hope this will help.

Best regards,

    Alex

------------------
Computer sind unbrauchbar. Sie können nur Fragen beantworten.
Pablo Picasso, Maler

Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP

Andylau
Mitglied



Sehen Sie sich das Profil von Andylau an!   Senden Sie eine Private Message an Andylau  Schreiben Sie einen Gästebucheintrag für Andylau

Beiträge: 55
Registriert: 07.06.2021

erstellt am: 14. Okt. 2021 17:21    Editieren oder löschen Sie diesen Beitrag!  <-- editieren / zitieren -->   Antwort mit Zitat in Fett Antwort mit kursivem Zitat    Unities abgeben: 1 Unity (wenig hilfreich, aber dennoch)2 Unities3 Unities4 Unities5 Unities6 Unities7 Unities8 Unities9 Unities10 Unities

Hi Alex,

Thanks for you tips!
But the result of parts_before and parts_after are the same.
They have no difference at all. That's the problem.
Maybe the result of sd-put-buffer can't ouput immediately?

BTW, someone is looking for Mr. Clausb. I left him a private message in this forum.

Zitat:
Original erstellt von AlexG:
Hi Andy,

Unfortunately, since I can't test the code, I can only make guesses. Maybe it helps to determine the result of the two lists parts_before and parts_after by means of SET-DIFFERENCE http://clhs.lisp.se/Body/f_set_di.htm. This has worked well for me in the past.

Anyhow to provide somehow more information on events. They should work like this:

Code:

(defun event-test-function (arg &rest more-args)
  "Just a dummy function. This function is called when the event gets triggered."
  (display (format nil "Event was triggered with argument '~a'~@[ and even more arguments '~a'~]" arg more-args)))

;; Subscribe event
(oli:sd-subscribe-event oli:*sd-change-object-tree-event* 'event-test-function "Some arguments")


(Manually) triggere event. Event *sd-change-object-tree-event* also is fired if something has changed in the object tree/browser view:

Code:
(oli:sd-process-event oli:*sd-change-object-tree-event* 42 '("the" "answer" "is"))

Additional information. To unsubscribe event use:

Code:
(oli:sd-unsubscribe-event oli:*sd-change-object-tree-event* 'event-test-function)

For even more detailed information refere to http://www.clausbrod.de/cgi-bin/view.pl/CoCreateModeling/MacroAlarmClock

I hope this will help.

Best regards,

    Alex


Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP

der_Wolfgang
Ehrenmitglied V.I.P. h.c.
Tastenhauer


Sehen Sie sich das Profil von der_Wolfgang an!   Senden Sie eine Private Message an der_Wolfgang  Schreiben Sie einen Gästebucheintrag für der_Wolfgang

Beiträge: 2017
Registriert: 3.20.

● PE60+80@home
● W10 Pro Build19044.2364
● Drafting V17~V20.5.1
● Modeling V17~V20.5.1

erstellt am: 14. Okt. 2021 20:22    Editieren oder löschen Sie diesen Beitrag!  <-- editieren / zitieren -->   Antwort mit Zitat in Fett Antwort mit kursivem Zitat    Unities abgeben: 1 Unity (wenig hilfreich, aber dennoch)2 Unities3 Unities4 Unities5 Unities6 Unities7 Unities8 Unities9 Unities10 Unities Nur für Andylau 10 Unities + Antwort hilfreich

sd-put-buffer is the last and worst solution from my point of view and always a dirty workarround (except you do well designed UI as input-tool for an action routine)

Modeling need to be interactice to execute what you put-buffer'ed. Therefore it's a no-go for any kind of programatically usage.

-----------------------------

Last but not least.  YOUR questions, Andy, should go to the international forum. You complain that there is no traffic over there    and on the other side you DON'T MAKE TRAFFIC over there.

------------------
Firefox ESRJava Forum Stuttgart JUGS ● OSD Hilfeseite (de) / help page (en)NotePad++BuFDi

Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP

Andylau
Mitglied



Sehen Sie sich das Profil von Andylau an!   Senden Sie eine Private Message an Andylau  Schreiben Sie einen Gästebucheintrag für Andylau

Beiträge: 55
Registriert: 07.06.2021

erstellt am: 15. Okt. 2021 06:49    Editieren oder löschen Sie diesen Beitrag!  <-- editieren / zitieren -->   Antwort mit Zitat in Fett Antwort mit kursivem Zitat    Unities abgeben: 1 Unity (wenig hilfreich, aber dennoch)2 Unities3 Unities4 Unities5 Unities6 Unities7 Unities8 Unities9 Unities10 Unities

Hi Wolfgang,

I already know that's the problem of sd-put-buffer.
But the question is now back to the correct use of

ts-catalog-laden-dialog

I just don't know how to use this to load standard parts in macro. sd-put-buffer can make the load, but without running immediately. So I can't find the parts_after correctly.

I'm sorry I can't speak German. I post here just want to get help faster. But before my every post, I have already searched the international forum and this forum for the possible answers.



Zitat:
Original erstellt von der_Wolfgang:
sd-put-buffer is the last and worst solution from my point of view and always a dirty workarround (except you do well designed UI as input-tool for an action routine)

Modeling need to be interactice to execute what you put-buffer'ed. Therefore it's a no-go for any kind of programatically usage.


Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP

Andylau
Mitglied



Sehen Sie sich das Profil von Andylau an!   Senden Sie eine Private Message an Andylau  Schreiben Sie einen Gästebucheintrag für Andylau

Beiträge: 55
Registriert: 07.06.2021

erstellt am: 18. Okt. 2021 17:09    Editieren oder löschen Sie diesen Beitrag!  <-- editieren / zitieren -->   Antwort mit Zitat in Fett Antwort mit kursivem Zitat    Unities abgeben: 1 Unity (wenig hilfreich, aber dennoch)2 Unities3 Unities4 Unities5 Unities6 Unities7 Unities8 Unities9 Unities10 Unities


testcode4.lsp

 
I found another function: TS-CAT-UICT-SELECT-PART
but still didn't work.

Code:

(ts-catalog-laden-dialog
:neu :on
:TBGR-IN-MEMORY
(TS-CAT-UICT-SELECT-PART
"PARAMETER"
"normteile/scheiben/din_125a"
"0000000000"
" 'NAME_ORIG' 'DN' 'H' 'DI' 'DA' 'PNR' 'SID' 'DESCRIPTION_ORIG'
'NAME' 'BEZEICHNUNG' 'DELETE' 'FAVORITE'"
" 'Scheibe_A_10_5_DIN_125' '10' '2' '10.5' '20' ''
'din125a_10_2_10.5_20' 'Scheibe DIN 125 - A10.5' 'Washer_DIN_125-
A10.5' 'Washer DIN 125 - A10.5' '' ''"
" "
" "
)
:BESITZER (sd-pathname-to-obj "/")
:positioning (gpntwc 0 0 0 "vport1")
complete
)


Zitat:
Original erstellt von Andylau:
Hi Wolfgang,

I already know that's the problem of sd-put-buffer.
But the question is now back to the correct use of

ts-catalog-laden-dialog

I just don't know how to use this to load standard parts in macro. sd-put-buffer can make the load, but without running immediately. So I can't find the parts_after correctly.

I'm sorry I can't speak German. I post here just want to get help faster. But before my every post, I have already searched the international forum and this forum for the possible answers.



Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP

MiBr
Mitglied
Konstrukteur


Sehen Sie sich das Profil von MiBr an!   Senden Sie eine Private Message an MiBr  Schreiben Sie einen Gästebucheintrag für MiBr

Beiträge: 508
Registriert: 30.06.2015

HP Z440 Workstation 64GB
Modeling 20.1.2.0 (x64)
Drafting 20.1.2.0 (64x) klas. UI
Modell Manager 20.1.2.0
Ansys Workbeanch 19R3 Mechanical Pro

erstellt am: 19. Okt. 2021 13:45    Editieren oder löschen Sie diesen Beitrag!  <-- editieren / zitieren -->   Antwort mit Zitat in Fett Antwort mit kursivem Zitat    Unities abgeben: 1 Unity (wenig hilfreich, aber dennoch)2 Unities3 Unities4 Unities5 Unities6 Unities7 Unities8 Unities9 Unities10 Unities Nur für Andylau 10 Unities + Antwort hilfreich


testcode_5.lsp

 
Hello,

I have a very bad solution for the problem with the sd-put-buffer.
Use a second dialog, really bad but it works.
But in your Lisp, i don´t know!

Greetz Michael

Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP



Technischer Qualitätsmanager - Property Management (m/w/d)

...ist Deutschlands größte öffentlich-rechtliche Versorgungsgruppe mit 2,5 Mio. Versicherten und Versorgungsempfängern

...ist mit einem Kapitalanlagevolumen (Marktwert) von 106,8 Mrd. Euro Deutschlands Nummer 1 unter den Altersversorgern

...ist mit ihren rund 1.480 Mitarbeitenden modernes Wirtschaftsunternehmen und staatliche Oberbehörde in einem


  • Durchführung von Objektkontrollen, Gewährleistung sicherheitsrelevanter Anforderungen i....
Anzeige ansehenQualitätsmanagement
Andylau
Mitglied



Sehen Sie sich das Profil von Andylau an!   Senden Sie eine Private Message an Andylau  Schreiben Sie einen Gästebucheintrag für Andylau

Beiträge: 55
Registriert: 07.06.2021

erstellt am: 19. Okt. 2021 14:10    Editieren oder löschen Sie diesen Beitrag!  <-- editieren / zitieren -->   Antwort mit Zitat in Fett Antwort mit kursivem Zitat    Unities abgeben: 1 Unity (wenig hilfreich, aber dennoch)2 Unities3 Unities4 Unities5 Unities6 Unities7 Unities8 Unities9 Unities10 Unities

Hi, Michael,

Thanks a lot. It tried it and it works. but I think I have to find a solution without sd-put-buffer.
I will really use sd-put-buffer in a loop, I'm afraid it will overflow.
It is weird that there is no related document for the loading of standard parts, and I can't find an example.

Code:

(sd-put-buffer value)
Description:
Function to feed any value to PTC Creo Elements/Direct Modeling's command line buffer. This function does the same as you would do if you enter (type in) value in PTC Creo Elements/Direct Modeling's enter command line.
Whenever you want to input data to a running PTC Creo Elements/Direct Modeling command via a user interface control (using one of its actions, e.g. :pushAction of a push button control) you have to use this function.
Note: Execution of value starts, as soon as PTC Creo Elements/Direct Modeling requires interactive input from the user. That means if you feed multiple values to PTC Creo Elements/Direct Modeling's command buffer within a LISP loop and you never give PTC Creo Elements/Direct Modeling a chance to become interactive to start execution of the commands in the command buffer, you can easily fill up the command buffer until it overflows.

Zitat:
Original erstellt von MiBr:
Hello,

I have a very bad solution for the problem with the sd-put-buffer.
Use a second dialog, really bad but it works.
But in your Lisp, i don´t know!

Greetz Michael


Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP

Anzeige.:

Anzeige: (Infos zum Werbeplatz >>)

Darstellung des Themas zum Ausdrucken. Bitte dann die Druckfunktion des Browsers verwenden. | Suche nach Beiträgen

nächster neuerer Beitrag | nächster älterer Beitrag
Antwort erstellen


Diesen Beitrag mit Lesezeichen versehen ... | Nach anderen Beiträgen suchen | CAD.de-Newsletter

Administrative Optionen: Beitrag schliessen | Archivieren/Bewegen | Beitrag melden!

Fragen und Anregungen: Kritik-Forum | Neues aus der Community: Community-Forum

(c)2023 CAD.de | Impressum | Datenschutz