lamensterms Posted August 30, 2012 Posted August 30, 2012 Hi guys, I've been planning to teach myself how to use LISP with ProSteel, unfortunately there are few resources to learn - and I havent had too much spare time in which I can study it. I was just wondering if I could please get some input and help putting together a routine which would read and write data attached to ProSteel entities. For those who are familiar with ProSteel... The idea is quite simple... I would like to fill in the "NOTE 2" field with a string compiled from the "SHIP No." and "POS No." fields - as well as fill in the "POS No." field with the "GRIP LENGTH" field. The application is for labeling bolts with the information as to what items they are bolting together. Example (Please see attached JPEG)... There is a bolt which connects "ITEM 1" to "ITEM 2" Item 1 Data POS No. = f1001 SHIP No. = A1001 Item 2 Data SHIP No. = B1001 Bolt Data GRIP LENGTH = 24 I would like to be able to extract the "SHIP No." and the "POS No." from "ITEM 1" as well as the "SHIP No." from "ITEM 2" and compile it into a string, and place that string into the "NOTE 2" field of the bolt. I would also like to transfer the "GRIP LENGTH" value from the bolt and put it into the "POS No." field of the bolt. Bolt Data NOTE 2 = "ITEM 1 SHIP No." ("ITEM 1 POS No.") TO "ITEM 2 SHIP No." = A1001 (f1001) TO B1001 POS No. = GRIP LENGTH = 24 This would ideally be achieved by selecting the bolts first, then picking "ITEM 1", then picking "ITEM 2". Thank you all very much for all your help. Cheers Quote
carry Posted August 30, 2012 Posted August 30, 2012 hi lamensterms see https://sites.google.com/site/mclisp/richieste-utenti ciao Quote
lamensterms Posted September 3, 2012 Author Posted September 3, 2012 (edited) Hi Carry, Thanks again for all your help... please see my version of the routine below: ; This routine assigns bolting data to bolts. Allowing bolts to be exported ; with correct material list LOCATION and GRIP data. ;----------------------------------------------------------------------------- ; MAIN PROGRAM ;----------------------------------------------------------------------------- ;--------------------------Read Data From Item 1------------------------------ (defun c:abd (/ acadapp shapeinfo ent ent1 Note1s1 Note2s1 ShipNumberS1 PosNumberS1 ent2 ent2A ent2B ShipNumberS2 ent3 ent3A ent3B GRIP LOCATION vObje) (vl-load-com) (setq acadapp (vlax-get-acad-object)) (setq shapeinfo (vla-getinterfaceobject acadapp "PSCOMWRAPPER.Ks_ComShapeInfo")) (setq ent (entsel "\nSelect 1 shape: ")) (setq ent (car ent)) (setq ent1 ent) (vlax-invoke-method shapeinfo 'setobject (vlax-ename->vla-object ent)) (vlax-invoke-method shapeinfo 'getinfo);ritrova le informazioni nel database (setq shapeinfo (vla-getinterfaceobject acadApp "PSCOMWRAPPER.Ks_ComShape")) (setq shapeinfo (vlax-ename->vla-object ent1)) (setq Note1s1 (vlax-get-property shapeinfo 'Note1)) ;Note1shape1 (setq Note2s1 (vlax-get-property shapeinfo 'Note2)) ;Note2shape1 (setq ShipNumberS1 (vlax-get-property shapeinfo 'ShipNumber)) ;shape1 (setq PosNumberS1 (vlax-get-property shapeinfo 'PosNumber)) ;shape1 (vlax-release-object shapeinfo) (setq shapeinfo nil) (setq acadApp nil)(princ) ;***************************************************************************** ;--------------------------Read Data From Item 2------------------------------ (setq acadapp (vlax-get-acad-object)) (setq shapeinfo (vla-getinterfaceobject acadapp "PSCOMWRAPPER.Ks_ComShapeInfo")) (setq ent2 (entsel "\nSelect 2 shape: ")) (setq ent2A (car ent2)) (setq ent2B ent2A) (vlax-invoke-method shapeinfo 'setobject (vlax-ename->vla-object ent2A)) (vlax-invoke-method shapeinfo 'getinfo);ritrova le informazioni nel database (setq shapeinfo (vla-getinterfaceobject acadApp "PSCOMWRAPPER.Ks_ComShape")) (setq shapeinfo (vlax-ename->vla-object ent2B)) (setq ShipNumberS2 (vlax-get-property shapeinfo 'ShipNumber)) ;Ship Number Shape 2 (vlax-release-object shapeinfo) (setq shapeinfo nil) (setq acadApp nil)(princ) ;***************************************************************************** ;--------------------------Read Data From Bolt-------------------------------- (setq acadapp (vlax-get-acad-object)) (setq shapeinfo (vla-getinterfaceobject acadapp "PSCOMWRAPPER.Ks_ComShapeInfo")) (setq ent3 (entsel "\nSelect BOLT: ")) (setq ent3A (car ent3)) (setq ent3B ent3A) (vlax-invoke-method shapeinfo 'setobject (vlax-ename->vla-object ent3A)) (vlax-invoke-method shapeinfo 'getinfo);ritrova le informazioni nel database (setq shapeinfo (vla-getinterfaceobject acadApp "PSCOMWRAPPER.Ks_ComShape")) (setq shapeinfo (vlax-ename->vla-object ent3B)) (setq GRIP (vlax-get-property shapeinfo 'KlemmLength)) ;Bolt Grip (vlax-release-object shapeinfo) (setq shapeinfo nil) (setq acadApp nil)(princ) ;***************************************************************************** ;--------------------------Write Data To Bolt--------------------------------- (setq LOCATION (strcat ShipNumberS1 " ("PosNumberS1") TO "ShipNumberS2)) (setq vObje (vlax-ename->vla-object ent3a));Bolt (vlax-put-property vObje 'PosNumber GRIP) (vlax-put-property vObje 'Note2 LOCATION) (vlax-put-property vObje 'ShipNumber ShipNumberS1) ) (print "Type ABD to run") All credit to Carry - https://sites.google.com/site/mclisp/richieste-utenti A lot of the code is a little too sophisticated for me - but I did manage to get the routine to almost work correctly. The process for the user is: 1 - Run command 2 - Pick first bolting object 3 - Pick second bolting object 4 - Pick bolt The routine will read certain data from each object picked, and then assign it to the appropriate field in the bolt's properties. The only issue I have with the way this routine works is... it only operates on a single bolt selected. I think this is because the routine requires a LIST as the selection set. I was just wondering if anyone could please help me create a multiple item LIST to allow the routine to operate on multiple BOLTS. The first two components picked should stay a single item LISTS. Thanks again for your help Carry. Cheers. Edited September 3, 2012 by lamensterms Quote
carry Posted September 3, 2012 Posted September 3, 2012 hi lamensterms thanks see https://sites.google.com/site/mclisp/richieste-utenti ciao Quote
lamensterms Posted September 4, 2012 Author Posted September 4, 2012 Awesome, thanks a lot Carry. ;----------------------------------------------------------------------------- ; MAIN PROGRAM ;----------------------------------------------------------------------------- ;--------------------------Read Data From Item 1------------------------------ (defun c:abd (/ acadapp shapeinfo ent ent1 Note1s1 Note2s1 ShipNumberS1 PosNumberS1 ent2 ent2A ent2B ShipNumberS2 ent3 ent3A ent3B GRIP LOCATION vObje con num) (vl-load-com) (setq acadapp (vlax-get-acad-object)) (setq shapeinfo (vla-getinterfaceobject acadapp "PSCOMWRAPPER.Ks_ComShapeInfo")) (setq ent (entsel "\nSelect 1 shape: ")) (setq ent (car ent)) (setq ent1 ent) (vlax-invoke-method shapeinfo 'setobject (vlax-ename->vla-object ent)) (vlax-invoke-method shapeinfo 'getinfo);ritrova le informazioni nel database (setq shapeinfo (vla-getinterfaceobject acadApp "PSCOMWRAPPER.Ks_ComShape")) (setq shapeinfo (vlax-ename->vla-object ent1)) (setq Note1s1 (vlax-get-property shapeinfo 'Note1)) ;Note1shape1 (setq Note2s1 (vlax-get-property shapeinfo 'Note2)) ;Note2shape1 (setq ShipNumberS1 (vlax-get-property shapeinfo 'ShipNumber)) ;shape1 (setq PosNumberS1 (vlax-get-property shapeinfo 'PosNumber)) ;shape1 (vlax-release-object shapeinfo) (setq shapeinfo nil) (setq acadApp nil)(princ) ;***************************************************************************** ;--------------------------Read Data From Item 2------------------------------ (setq acadapp (vlax-get-acad-object)) (setq shapeinfo (vla-getinterfaceobject acadapp "PSCOMWRAPPER.Ks_ComShapeInfo")) (setq ent2 (entsel "\nSelect 2 shape: ")) (setq ent2A (car ent2)) (setq ent2B ent2A) (vlax-invoke-method shapeinfo 'setobject (vlax-ename->vla-object ent2A)) (vlax-invoke-method shapeinfo 'getinfo);ritrova le informazioni nel database (setq shapeinfo (vla-getinterfaceobject acadApp "PSCOMWRAPPER.Ks_ComShape")) (setq shapeinfo (vlax-ename->vla-object ent2B)) (setq ShipNumberS2 (vlax-get-property shapeinfo 'ShipNumber)) ;Ship Number Shape 2 (vlax-release-object shapeinfo) (setq shapeinfo nil) (setq acadApp nil)(princ) ;***************************************************************************** ;--------------------------Read Data From Bolt-------------------------------- (prompt "\nSelect BOLT:")(princ) (setq ss (ssget '((0 . "KS_BOLT"))));8=Name Layer 0=ks_object (setq num (sslength ss));n° object (setq con 0) (repeat num (setq ent3A (ssname ss con)) ; (entsel "\nSelect BOLT: ")) (setq ent3B ent3A) (setq acadapp (vlax-get-acad-object)) (setq shapeinfo (vla-getinterfaceobject acadapp "PSCOMWRAPPER.Ks_ComShapeInfo")) (vlax-invoke-method shapeinfo 'setobject (vlax-ename->vla-object ent3A)) (vlax-invoke-method shapeinfo 'getinfo);ritrova le informazioni nel database (setq shapeinfo (vla-getinterfaceobject acadApp "PSCOMWRAPPER.Ks_ComShape")) (setq shapeinfo (vlax-ename->vla-object ent3B)) (setq GRIP (vlax-get-property shapeinfo 'KlemmLength)) ;Bolt Grip (vlax-release-object shapeinfo) (setq shapeinfo nil) (setq acadApp nil)(princ) (setq con (1+ con)) ;***************************************************************************** ;--------------------------Write Data To Bolt--------------------------------- (setq LOCATION (strcat ShipNumberS1 " (" PosNumberS1") TO "ShipNumberS2)); 10 ( 1 (setq vObje (vlax-ename->vla-object ent3a));Bolt (vlax-put-property vObje 'PosNumber GRIP) (vlax-put-property vObje 'Note2 LOCATION) (vlax-put-property vObje 'ShipNumber ShipNumberS1) ) ) (print "Type ABD to run") Quote
lamensterms Posted November 14, 2012 Author Posted November 14, 2012 Just one more question on this routine (which is otherwise working great)... The final value for GRIP - (setq GRIP (vlax-get-property shapeinfo 'KlemmLength)) - i wish to be a round number/integer. Is there a function which will convert this real number to an integer (similar to RTOS and ATOI and such) which will round up or down to the nearest whole number? Thanks for any help. Quote
carry Posted November 14, 2012 Posted November 14, 2012 hi lamensterms (setq GRIP (fix (vlax-get-property shapeinfo 'KlemmLength))) ;Bolt Grip ciao Quote
lamensterms Posted November 15, 2012 Author Posted November 15, 2012 That’s fantastic, thanks a lot Carry. If possible, may I please have your assistance with another routine I’ve been working on? I used your code from above as a base – just modified a few variables. The idea is that I would like to be able to add a prefix or a suffix to any Part Position Number, Part Shipping Number, Group Position Number or Group Shipping number. The code below will operate fine for adding any specified prefix or suffix to a Part Position or Part Shipping Number. Do you have any suggestions as to how I can tweak it to operated on Group Position and Shipping Numbers? Thanks so much for all your help. (defun c:possuf (/ ss num con ent3A ent3B acadapp shapeinfo CPOS NPOS acadApp) ;--------------------------Read Data From Element------------------------------ (prompt "\nSelect ELEMENTS:")(princ) (setq ss (ssget));8=Name Layer 0=ks_object (setq num (sslength ss));n° object (setq con 0) (repeat num (setq ent3A (ssname ss con)) (setq ent3B ent3A) (setq acadapp (vlax-get-acad-object)) (setq shapeinfo (vla-getinterfaceobject acadapp "PSCOMWRAPPER.Ks_ComShapeInfo")) (vlax-invoke-method shapeinfo 'setobject (vlax-ename->vla-object ent3A)) (vlax-invoke-method shapeinfo 'getinfo);ritrova le informazioni nel database (setq shapeinfo (vla-getinterfaceobject acadApp "PSCOMWRAPPER.Ks_ComShape")) (setq shapeinfo (vlax-ename->vla-object ent3B)) (setq CPOS (vlax-get-property shapeinfo 'PosNumber)) ;Position Number (setq NPOS (strcat CPOS "abc")) (vlax-release-object shapeinfo) (setq shapeinfo nil) (setq acadApp nil)(princ) (setq con (1+ con)) ;***************************************************************************** ;--------------------------Write Data To Element------------------------------ (setq vObje (vlax-ename->vla-object ent3a)); (vlax-put-property vObje 'PosNumber NPOS) ) ) Quote
carry Posted November 15, 2012 Posted November 15, 2012 hi lamensterms see ShipNumber Property Sets or retrieves the shipping number of the object. Signature Value = Object.ShipNumber Object.ShipNumber = Value Object Ks_ComArcPlate Ks_ComArcShape Ks_ComBendShape Ks_ComBolt Ks_ComGroupProperty Ks_ComPlate Ks_ComPositionFlag Ks_ComProperty Ks_ComShape Ks_ComVolBody Value string Shipping number of the object Properties ShipNumber Property Sets or retrieves the shipping number of the object. Signature Value = Object.ShipNumber Object.ShipNumber = Value Quote
btsai Posted April 12, 2020 Posted April 12, 2020 hi all, i am trying very hard to try to extract group number This is what i tried (defun c:gpossuf (/ ss num con ent3A ent3B acadapp shapeinfo CPOS NPOS acadApp) ;--------------------------Read Data From Element------------------------------ (prompt "\nSelect ELEMENTS:")(princ) (setq ss (ssget));8=Name Layer 0=ks_object (setq num (sslength ss));n° object (setq con 0) (repeat num (setq ent3A (ssname ss con)) (setq ent3B ent3A) (setq acadapp (vlax-get-acad-object)) (setq shapeinfo (vla-getinterfaceobject acadapp "PSCOMWRAPPER.Ks_ComGroupPropertyInfo")) (vlax-invoke-method shapeinfo 'setobject (vlax-ename->vla-object ent3A)) (vlax-invoke-method shapeinfo 'getinfo);ritrova le informazioni nel database (setq shapeinfo (vla-getinterfaceobject acadApp "PSCOMWRAPPER.Ks_ComGroupProperty")) (setq shapeinfo (vlax-ename->vla-object ent3B)) (setq CPOS (vlax-get-property shapeinfo 'grpposnumber)) ;Position Number (setq NPOS (strcat CPOS "abc")) (vlax-release-object shapeinfo) (setq shapeinfo nil) (setq acadApp nil)(princ) (setq con (1+ con)) ;***************************************************************************** ;--------------------------Write Data To Element------------------------------ (setq vObje (vlax-ename->vla-object ent3a)); (vlax-put-property vObje 'PosNumber NPOS) ) ) It is the same as the previous except for "Ks_ComGroupProperty" and "grpposnumber" and i am not even sure if those variables/libraries are correct So long as i can see the group number has 'abc', then i'll know that it works but i keep failing. Also, the google website in this thread no longer works . Please help Quote
lamensterms Posted April 18, 2020 Author Posted April 18, 2020 Hi btsai, Please try codes below showing some methods of extracting data from ProSteel groups, hope they are useful for you. Dump all available properties: (defun C:DumpItG ( / ent) (setq ent (entsel)) (setq acadapp (vlax-get-acad-object)) (setq groupinfo (vla-getinterfaceobject acadapp "PSCOMWRAPPER.Ks_ComGroupProperty" )) (vlax-invoke-method groupinfo 'ReadFrom (vlax-ename->vla-object (car ent))) (vlax-Dump-Object groupinfo ) (textscr) (princ) ) Example of extracting each property to variable: (defun c:GroupProperty ( ) (vl-load-com) (setq acadapp (vlax-get-acad-object)) (setq groupinfo (vla-getinterfaceobject acadapp "PSCOMWRAPPER.Ks_ComGroupProperty" )) (setq ent (entsel "\nSelect group: " )) (setq ent (car ent)) (vlax-invoke-method groupinfo 'ReadFrom (vlax-ename->vla-object ent)) (setq Count (vlax-get-property groupinfo 'Count)) (setq DetailStyleId (vlax-get-property groupinfo 'DetailStyleId)) (setq DontDetailFlag (vlax-get-property groupinfo 'DontDetailFlag)) (setq FamilyClass (vlax-get-property groupinfo 'FamilyClass)) (setq GroupHeight (vlax-get-property groupinfo 'GroupHeight)) (setq GroupLength (vlax-get-property groupinfo 'GroupLength)) (setq GroupPaintArea (vlax-get-property groupinfo 'GroupPaintArea)) (setq GroupWeight (vlax-get-property groupinfo 'GroupWeight)) (setq GroupWidth (vlax-get-property groupinfo 'GroupWidth)) (setq IsMainPart (vlax-get-property groupinfo 'IsMainPart)) (setq ItemNumber (vlax-get-property groupinfo 'ItemNumber)) (setq Name (vlax-get-property groupinfo 'Name)) (setq NameChangedManually (vlax-get-property groupinfo 'NameChangedManually)) (setq Note1 (vlax-get-property groupinfo 'Note1)) (setq Note2 (vlax-get-property groupinfo 'Note2)) (setq OriginalPosNumber (vlax-get-property groupinfo 'OriginalPosNumber)) (setq PartlistFlag (vlax-get-property groupinfo 'PartlistFlag)) (setq PosNumber (vlax-get-property groupinfo 'PosNumber)) (setq PosNumberChangedFlag (vlax-get-property groupinfo 'PosNumberChangedFlag)) (setq ShipNumber (vlax-get-property groupinfo 'ShipNumber)) (setq TotalCount (vlax-get-property groupinfo 'TotalCount)) (princ "\n") (princ Count ) (princ "\n") (princ DetailStyleId ) (princ "\n") (princ DontDetailFlag ) (princ "\n") (princ FamilyClass ) (princ "\n") (princ GroupHeight ) (princ "\n") (princ GroupLength ) (princ "\n") (princ GroupPaintArea ) (princ "\n") (princ GroupWeight ) (princ "\n") (princ GroupWidth ) (princ "\n") (princ IsMainPart ) (princ "\n") (princ ItemNumber ) (princ "\n") (princ Name ) (princ "\n") (princ NameChangedManually ) (princ "\n") (princ Note1 ) (princ "\n") (princ Note2 ) (princ "\n") (princ OriginalPosNumber ) (princ "\n") (princ PartlistFlag ) (princ "\n") (princ PosNumber ) (princ "\n") (princ PosNumberChangedFlag ) (princ "\n") (princ ShipNumber ) (princ "\n") (princ TotalCount ) ;(setq vObje (vlax-ename->vla-object ent));Bolt ;(vlax-put-property groupinfo 'Name "TEST") ;(princ (strcat (rtos count 2 0) " - " name)) (princ) ) 1 Quote
btsai Posted April 26, 2020 Posted April 26, 2020 hi lamensterms I'm finally able to extract the information I need (and more). Thanks a lot Quote
bra888 Posted May 11, 2021 Posted May 11, 2021 hi all i tried the following codes (defun c:itemProperty ( ) (vl-load-com) (setq acadapp (vlax-get-acad-object)) (setq shapeinfo (vla-getinterfaceobject acadapp "PSCOMWRAPPER.Ks_ComShapeInfo" )) (setq ent (entsel "\nSelect group: " )) (setq ent (car ent)) (vlax-invoke-method shapeinfo 'setobject (vlax-ename->vla-object ent)) (vlax-invoke-method shapeinfo 'getinfo); (setq shapeinfo (vla-getinterfaceobject acadapp "PSCOMWRAPPER.Ks_ComShape" )) (setq shapeinfo (vlax-ename->vla-object ent)) (setq Note1 (vlax-get-property shapeinfo 'Note1)) (princ Note1 ) (princ "\n") (setq vObje (vlax-ename->vla-object ent)) (vlax-put-property vObje 'Note1 "TESTx") ;(princ (strcat (rtos count 2 0) " - " name)) (princ) ) and i am able to extract the Note1 of an object and overwrite with "TEXTx" However when I tried (defun c:itemProperty ( ) (vl-load-com) (setq acadapp (vlax-get-acad-object)) (setq shapeinfo (vla-getinterfaceobject acadapp "PSCOMWRAPPER.Ks_ComShapeInfo" )) (setq ent (entsel "\nSelect group: " )) (setq ent (car ent)) (vlax-invoke-method shapeinfo 'setobject (vlax-ename->vla-object ent)) (vlax-invoke-method shapeinfo 'getinfo); (setq shapeinfo (vla-getinterfaceobject acadapp "PSCOMWRAPPER.Ks_ComShape" )) (setq shapeinfo (vlax-ename->vla-object ent)) (setq dc (vlax-get-property shapeinfo 'DisplayClassName)) (princ dc ) (princ "\n") (setq vObje (vlax-ename->vla-object ent)) (vlax-put-property vObje 'DisplayClassName "Bolts") ;(princ (strcat (rtos count 2 0) " - " name)) (princ) ) i am able to extract the display class name of an object, but unable to overwrite/assign the display class Is there something I am missing? Please help. Quote
lamensterms Posted May 12, 2021 Author Posted May 12, 2021 Hi bra888, Unfortunately there are some fields which are read-only, and cannot be written to outside of the ProSteel functions. You can use the routine below, to get a list of each field, value and also shows a read-only flag "(RO)". Credit to BIGAL for Dumpit.LSP. ;;; Dump all methods and properties for selected objects ; ;;;===================================================================; ;;; DumpIt ; ;;;-------------------------------------------------------------------; ;;;===================================================================; (defun C:DumpIt ( / ent) ;(while (setq ent (entsel)) (vlax-Dump-Object (vlax-Ename->Vla-Object (car ent)) ) ;) (textscr) (princ) ) Using the above routine, you can see that Display Class is read only: Quote
bra888 Posted May 12, 2021 Posted May 12, 2021 hi lamensterms thanks for your reply. That is good to know otherwise I will be endlessly stuck in this method. is there any other way to assign display classes using lisp? Or does it require a different computer language? Quote
lamensterms Posted May 16, 2021 Author Posted May 16, 2021 Not that I'm aware of, it's beyond my LISP ability. To assign Display Classes, I use a combination of 2D Detail Centre + the Display Class tool. Are they not useful to you? Quote
devitg Posted May 18, 2021 Posted May 18, 2021 On 5/12/2021 at 1:16 PM, bra888 said: hi lamensterms thanks for your reply. That is good to know otherwise I will be endlessly stuck in this method. is there any other way to assign display classes using lisp? Or does it require a different computer language? this variable hold the classname (setq dc (vlax-get-property shapeinfo 'DisplayClassName)) I guess, I have not prosteel you can read only , not change Quote
bra888 Posted November 3, 2021 Posted November 3, 2021 Hi all I am trying to extract information from assembly (not group or subassembly) but i am having trouble using "PSCOMWRAPPER.Ks_ComGroupProperty" and knowing the variable name like 'PosNumber How do we go around extracting from what library and variable that we can extract, overwrite, or read-only? Quote
bra888 Posted November 8, 2021 Posted November 8, 2021 On 5/17/2021 at 6:47 AM, lamensterms said: Not that I'm aware of, it's beyond my LISP ability. To assign Display Classes, I use a combination of 2D Detail Centre + the Display Class tool. Are they not useful to you? They are but I was hoping I could automate display class assignment based on certain properties Quote
thanesh Posted March 16, 2022 Posted March 16, 2022 how to load the lisp file in prosteel and also where we can open the visual lisp environment Quote
Recommended Posts
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.