Program that creates a bunch of block references

Program that creates a bunch of block references

brandon_harper
Participant Participant
974 Views
1 Reply
Message 1 of 2

Program that creates a bunch of block references

brandon_harper
Participant
Participant

So for work I have created a program that creates piping drawings from many different existing blocks of pipes, flanges, and fittings.

 

The user runs the AutoDraw macro to start the drawing creation process.  Then the user goes through a series of about 10 userforms populated with radio buttons and combo boxes to specify each exact part.  After each userform is filled out and the "Done" command button is pushed, the program creates the associated block references and the next userform pops up.

 

My problem is that the program doesn't actually draw the block reference after pressing the done button even though the code does.  Instead, the user has to go through all 10 userforms and spec everything out with nothing physically getting drawn in modelspace until the last done button is pressed.  After the last form is done, the whole drawing gets created instantly.

 

I want the program to show each additional part on the DWG as each UF is completed, so if they picked the wrong part they will see it and can go back to fix it instead of having to run through the whole program again.

 

I am not really a good coder (mechanical engineer), so I probably didn't organize the program in a clean way.  Here is the jist:

 

Module 1:

-Define a bunch of global variables related to each specific part and part location

-Master subroutine that calls all the sub-functions

     *Call Draw 1

     *Call Draw 2

     *Etc

End Sub

-Then Draw1 function shows the Draw1 UF, the user selects identifying info, and the done button closes the UF

-Draw1 continues to take the info and select the proper block and places it where it needs to go....End Function

-Then Draw2 ........

And that is the module, and the whole program.

 

I've tried a lot of things to get the block references to draw and nothing has worked.  Made a Do loop timer to give Autocad time to put down the block references before the next UF is called.  Tried to split each function into a different module.  Tried to put the set block code into the done button of the UF and that didnt work.

 

Please help!

0 Likes
975 Views
1 Reply
Reply (1)
Message 2 of 2

norman.yuan
Mentor
Mentor

Since you can get all required user inputs and actually draw the whole thing at the end, so your issue is to organize the whole data inputting process and drawing process properly so that the entire process can be done in multiple stages. In that way, user can visually see the data being inputted correctly or not, and at any stage, user can choose go ahead to next step, or go back to re-do previous step (or even start over again). Of course, you may also want to give user option to go all the data inputs and only draw at the end.

 

So, it is really does not matter what AutoCAD draws block references or other types of entities. As long as each data input stage gathers enough information for AutoCAD to drawing something meaningful, your code would let AutoCAD drawing something, then ask user to confirm to go next step, or go back to the beginning of current step (data input). As you can see, you need to break your current code that draws all things at the end into multiple parts with each part using some data collected from a user form and only drawing portion of the final result. You now ends up with  a series of UserForm->Drawing code combination as one step of the multi-step work.

 

Yes, you'll need to be somewhat experienced in programming thinking to figure out the logic of such multi-step process. I am not sure what is the reason you could not get the block reference (or anything else, for that matter) be drawn (between the data input forms, I assume). It should not be a problem, if your code can drawing everything at the end. I do not see any reason of using timer either. But, without actually seeing your code (it would be a lot, right?), it is hard to comment.

 

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes