Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

help with repeat/while confusion

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
gcsjlewis
285 Views, 4 Replies

help with repeat/while confusion

I understand the basics here, but i am having an issue with trying to speed up my program to do what i want.  My program works, but with a repeat command set at some random integer it takes a long time to run.  And i find myself constantly changing that random integer to speed up my lisp.  So i think i want a while command but i need a little help with it.  This is the structureof my lisp:

(I am using autocad electrical 2011:)

 

(defun c: ()

(communicate with excel and get how many values are not blank in a specified column for a repeat count)

----in this specific case it returns a count of 60 which is correct  Lets call this repeat1

;;;once this happens, i also:

(using repeat1 i communicate with excel to get a count for another specific column that has an "X" in it)

----in this specific case it returns 31, which is correct.  lets call this repeat2

 

;; main part of the program once i have repeat2

 

(I grab a bunch of blocks and cycle through each block to grab specific attributes)

(using repeat2 i cycle through the excel spread sheet i have until the block attribute and the excel "cell" value match what i am looking for.

(this is where i do a bunch of stuff to get what i want )

 

//the problem here is it continues to repeat even after what i want matches

//or in some cases, i may be looking for the value in the 60th cell, but my counter still has to increment until it gets to the 60th value, which could

//take 5-10 mins.

); end repeat2

);end defun

 

I believe i have attached/modified everything needed to run my lisp.  When opened you will see there is a lot of information being passed back and forth.  As i said when everything is said and done, it does everything i want it too do, but i am constantly tweeking my code to speed it up, it would be nice to have the lisp do it automatically.  any help will be much appreciated.  and i will respond back asap with any questions...

 

Thanks!

 

4 REPLIES 4
Message 2 of 5
p_mcknight
in reply to: gcsjlewis

Personally I would loop through the excel list as you do in the beginning but instead of making integers, grab the info and put it in a list of lists in a variable.  If you have the attribute as the first item in your nested list, then you can simply run an assoc with the attribute on the list of lists that you created, get the info and be done.  This way, there will be no looping at all except at the very beginning when you create the list of the excel data.  Does this make sense?

Message 3 of 5
gcsjlewis
in reply to: p_mcknight

It gets tricky.....It seems I am doing a lot of looping so this is what I do:


- I loop through excel( for repeat counts)

- I loop through blocks

- I loop through excel (for information)

- Update blocks

So what you are saying is to create list of list like this?

( (everything I need in Row A) (everything I need in Row B)....etc)


Then do a " (car (nth (some incrementor) excel_list)) "
And if it matches the block attribute that I need, then do the change?




________________________________
The information contained in this message is intended only for the personal and confidential use of the recipient(s) named above. If the reader of this message is not the intended recipient or an agent responsible for delivering it to the intended recipient, you are hereby notified that you have received this document in error and that any review, dissemination, distribution, or copying of this message is strictly prohibited. If you have received this communication in error, please notify us immediately, and delete the original message.
Message 4 of 5
p_mcknight
in reply to: gcsjlewis

So I don;t have to look through all of your code, tell me what you are doing once you match the attribute and the cell.  Or are you matching block names and excel values and then attributes.  A little more info here on whether you are writing values out to excel, or into autocad attributes, or using the match to determine what layer to change things to, etc.  will help me give you a better direction to try.

Message 5 of 5
gcsjlewis
in reply to: p_mcknight

I guess that's where my problem is, I am doing a little of both......

I figured it out though,

What I was trying to do, is loop through each block in my drawing and get an attribute, while I am doing this I am looping through the spreadsheet to compare numbers, and when they match pull information from excel and put it into my block attributes.

For example:

One of the attributes could be "TAGA01","TAGA02", etc... So I was looping through until it found the attribute that exists.

So what was happening was, I was looping through the block around 40 times, and each time I looped through the block, I was looping through excel.

But you helped give me an idea, I realized I do not need to cycle through the blocks I could just "hardcode" to grab the attribute that's in the block. And then whatever is in the block use, and just loop through excel once.

I think I was just trying to do too much to ensure the right info is grabbed and verified, when I didn't need too.

But I ran and tested this a couple of times and it right information is being pulled and updated as I want and it is a lot quicker....thanks for responding......

________________________________
The information contained in this message is intended only for the personal and confidential use of the recipient(s) named above. If the reader of this message is not the intended recipient or an agent responsible for delivering it to the intended recipient, you are hereby notified that you have received this document in error and that any review, dissemination, distribution, or copying of this message is strictly prohibited. If you have received this communication in error, please notify us immediately, and delete the original message.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost