Jump to content

Recommended Posts

Posted (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 by aridzv
  • aridzv changed the title to catch an error and continue
Posted

@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...

 

Posted

@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.

Posted

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

 

Posted (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 by Steven P
Posted

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"

 

Posted
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.

Posted

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. 

Posted
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.

Posted
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)) )

 

Posted
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"...

Posted

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)
)
        

 

  • Like 1
  • Agree 1
  • Thanks 1
Posted

Need recent versions of Bricscad to work no property functions in V20.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...