aridzv Posted August 30, 2023 Share Posted August 30, 2023 (edited) Hi. I need to check if a property (bricscad parameter) exist in a block. I use this code: (if (setq x (getpropertyvalue ent "d1"))) if the parameter exist all is well and the lisp works, But if it doesn't exist, the lisp throws an error instead of taking the "IF" result as false and moving on. I have done countless searches on the issue and have not found a solution. I rely don't know how to solve this issue and I'll be glad for any help. thanks, aridzv. Edited August 30, 2023 by aridzv Quote Link to comment Share on other sites More sharing options...
hosneyalaa Posted August 30, 2023 Share Posted August 30, 2023 try mothed vlax-property-available-p https://documentation.help/AutoLISP-Functions/WS1a9193826455f5ff1a32d8d10ebc6b7ccc-67fc.htm Quote Link to comment Share on other sites More sharing options...
aridzv Posted August 30, 2023 Author Share Posted August 30, 2023 @hosneyalaa Hi and thanks for the reply. I tried it before and now again this way: (if (vlax-property-available-p obj "d1") (princ "YES") (princ "no") ) but in this case, if the property exist it dosn't get it - it always return "no"... I must catch the error and resume... Quote Link to comment Share on other sites More sharing options...
aridzv Posted August 30, 2023 Author Share Posted August 30, 2023 @hosneyalaa I changed the code a little to this: (princ (vlax-property-available-p obj 'd1)) and I get "Nill" even if the object have "d1" property. Quote Link to comment Share on other sites More sharing options...
rlx Posted August 30, 2023 Share Posted August 30, 2023 what is property 'd1 or "d1" ? (vlax-property-available-p obj prop [check-modify]) property can be someting like color or (has) textstring or maybe visibility state. Looks like you trying to find the value for a property And check-modify also checks if property can be modified Quote Link to comment Share on other sites More sharing options...
Steven P Posted August 30, 2023 Share Posted August 30, 2023 (edited) Can you get a list of all the blocks properties? Compare 'd1' against that list and continue Edit Are these dynamic blocks, there might be something like vla-getdynamicblockproperties Edited August 30, 2023 by Steven P Quote Link to comment Share on other sites More sharing options...
aridzv Posted August 30, 2023 Author Share Posted August 30, 2023 Hi @rlx. 5 minutes ago, rlx said: what is property 'd1 or "d1" ? (vlax-property-available-p obj prop [check-modify]) property can be someting like color or (has) textstring or maybe visibility state. Looks like you trying to find the value for a property And check-modify also checks if property can be modified d1 is a string, see here how it looks in the output of (dumpallproperties (entlast)): ----- MCAD Properties Component file (ident: "Component file~MCAD") () = <no value> Instance name (ident: "Instance name~MCAD") (string) (RO) = <no value> d1 (ident: "d1~MCAD") (string) = "200" Quote Link to comment Share on other sites More sharing options...
aridzv Posted August 30, 2023 Author Share Posted August 30, 2023 5 minutes ago, Steven P said: Can you get a list of all the blocks properties? Compare 'd1' against that list and continue Edit Are these dynamic blocks, there might be something like vla-getdynamicblockproperties Hi @Steven P. 1. it is a Bricscad parametric block,quite similar to autocad dynamic blocks. 2. I used (dumpallproperties (entlast)) to get a screen print but I don't know how to get this to list and then search for it. Quote Link to comment Share on other sites More sharing options...
rlx Posted August 30, 2023 Share Posted August 30, 2023 haven't worked before with BricsCad so maybe this is one of those things just a little bit different, but dynamic (parametric) blocks have a way to give you gray hair. Think Bigal also uses BricsCad? Maybe he can give you better advice. Quote Link to comment Share on other sites More sharing options...
rlx Posted August 30, 2023 Share Posted August 30, 2023 maybe this helps : dynamic block prop 1 Quote Link to comment Share on other sites More sharing options...
aridzv Posted August 30, 2023 Author Share Posted August 30, 2023 14 minutes ago, rlx said: haven't worked before with BricsCad so maybe this is one of those things just a little bit different, but dynamic (parametric) blocks have a way to give you gray hair. Think Bigal also uses BricsCad? Maybe he can give you better advice. yapp... I'm close to ask bricscad support how to do it. 12 minutes ago, rlx said: maybe this helps : dynamic block prop checked it. return Nil... Select dynamic block: Select entities: Specify dynamic parameter name: d1 nil but thanks anyway. Quote Link to comment Share on other sites More sharing options...
Steven P Posted August 30, 2023 Share Posted August 30, 2023 11 minutes ago, rlx said: maybe this helps : dynamic block prop I'd read that one when I was having lunch, but went past it, lost the link by the time I replied. Will (dumpallproperties (entlast)) work if you put it inside a setq ? (setq allproperties (dumpallproperties (entlast)) ) Quote Link to comment Share on other sites More sharing options...
aridzv Posted August 30, 2023 Author Share Posted August 30, 2023 13 minutes ago, Steven P said: Will (dumpallproperties (entlast)) work if you put it inside a setq ? (setq allproperties (dumpallproperties (entlast)) ) tried it. it is printing to the screen but not storing it to "allproperties"... Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 30, 2023 Share Posted August 30, 2023 Since you're using BricsCAD, you can use the isPropertyValid function to test whether the property is valid prior to obtaining it, e.g.: (defun c:test ( / ent ) (if (setq ent (car (entsel))) (if (ispropertyvalid ent "d1~MCAD") (print (getpropertyvalue ent "d1~MCAD")) (princ "\nProperty not valid.") ) ) (princ) ) 1 1 1 Quote Link to comment Share on other sites More sharing options...
aridzv Posted August 30, 2023 Author Share Posted August 30, 2023 @Lee Mac MANY MANY THANKS - WORK PERFECT. aridzv. Quote Link to comment Share on other sites More sharing options...
rlx Posted August 30, 2023 Share Posted August 30, 2023 Lee (also) does BricsCad , yeah Quote Link to comment Share on other sites More sharing options...
BIGAL Posted August 31, 2023 Share Posted August 31, 2023 Need recent versions of Bricscad to work no property functions in V20. Quote Link to comment Share on other sites More sharing options...
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.