Jump to content

To check if a condition is true and do something for a block'd table


Recommended Posts

Posted (edited)

Hello, new to LISP here. 

The title might make it sound like the solution would be a simple if loop but sadly it's a tad more complicated. 

 

Here's what I'm trying to do:

I have a title block, it has an attribute that states the revision number. 

I got a variable (RevLatest) set in my code to read that revision number, say "F.0" for example. 

Now, I have a revision table, with 6 rows and 5 columns, the first column stating the previous and current revisions (A.0 to F.0). The revision table is a block with the information stored as attributes. 

The attributes for the revision numbers are named Rev_1, Rev_2, and so on. The same goes for the other info stored in that block, for eg., Rev_Description1-6, Rev_Date1-6, and so on. 

 

I want my program to check the first column of the revision table, check if it matches the number in the title block (F.0 in this example), and then read the information in that row only. 

So, if the title block revision is RB.0, I want the program to read the attributes' RevDescription2, RevDate2, etc. information. 

Here's the code I have, but I'm getting this error " ; error: bad function: "F.0" "

 

(while (<= cntr 6)
    (if (= (getpropertyvalue obj2 (strcat "REV_" (rtos cntr 2 0))) RevLatest)
      (progn
	(setq RevIFC (RevLatest))
	(setq DescIFC (getpropertyvalue obj2 (strcat "REV_DESCRIPTION" (rtos cntr 2 0))))
	(setq DateIFC (getpropertyvalue obj2 (strcat "REV_DATE" (rtos cntr 2 0))))
       )
    )
    (setq cntr (+ cntr 1))
   )

 

obj2 is the block name for the revision table

 

Please advise. 

Thanks for the help. 

Edited by G.Aquarius
Posted

Ok 1st up posting a dwg is always best as it shows what your working with.

 

I don't use set or get property as not supported in my Bricscad.

 

Just a comment I would probably convert the table block to a list of attributes easier to loop through. The other is I use creation order of blocks a lot as don't need to worry about tag names. 

 

If your creating a dwg index I make a "TABLE" it is created by reading from the layouts the title block attributes and populates a "TABLE" so if change revisions just delete and create again. Used this on 88 layouts dwg. Its fast. 

 

 

 

 

  • Like 1
Posted

Figured out why it's not working. I have an extra set of brackets around RevLatest, which was causing the issue. 

Remove that and it works perfectly. 

 

(setq RevIFC (RevLatest))

 

@BIGAL Thanks for the suggestions. I'll make sure to have a dwg attached next time I ask something :) 

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