Assign x,y coordinates based off of block instance insertion point

Assign x,y coordinates based off of block instance insertion point

brandon_harper
Participant Participant
1,102 Views
4 Replies
Message 1 of 5

Assign x,y coordinates based off of block instance insertion point

brandon_harper
Participant
Participant

I guess this question is in the correct place.  I am using scripts from Excel to Notepad to AutoCAD to auto draw fabrication drawings.

 

I created an Excel program that allows the user to select a bunch of parts from a master list of all parts.  Each part corresponds to an already built block in AutoCAD.  Currently the program spits out a list of insert scripts to drop all of the necessary blocks right next to each other for the user to then assemble.

(-insert "BLOCKNAME" X,Y 1 1 0)

 

And for the x and y I just increment the x values by 10 each time so all of my blocks are in a row.  Then I snap them all together by grabbing a parts insertion point and putting it on the appropriate point parameter on the frame. (I just made a bunch of point parameters on all possible snap points on the frame part that I can use.)

 

Is there a way using scripts to say "I want to insert this block on another blocks insertion point?" Or even better is to insert the block onto this specific block's "point snap A/B/C/etc"?

 

I am picturing something like this:

-insert "BLOCKNAME" DESTINATIONBLOCK.POINT_SNAP_A.Coordinates 1 1 0

or

-insert "BLOCKNAME" DESTINATIONBLOCK.Point_Snap_A.X , DESTINATIONBLOCK.Point_Snap_A.Y 1 1 0

 

At the end of the day I will not know the x and y coordinates that the block will need to go.

 

Also, if this cannot be done with scripts but is possible with LISP, y'all have any resources for LISP code writing?  I am fluent in VB and use it all the time for Excel background programs.

 

Thank you.

0 Likes
1,103 Views
4 Replies
Replies (4)
Message 2 of 5

john.uhden
Mentor
Mentor

There are many expert AutoLisp programmers who contribute their knowledge and time here in this discussion group.

In your situation, to save you time, I am envisioning something even better...

Maybe storing xrecord or xdata in each block so that we can automatically attach associated blocks to others at exactly where they would otherwise need to be placed manually, not just "near" each other.

 

Just a thought.

John F. Uhden

0 Likes
Message 3 of 5

brandon_harper
Participant
Participant

I will look into xData and see if I can maniplulate that to get it done.

 

After learning more about scripting I found out that it is the same as just typing commands in the command bar so I'm pretty sure I cannot use variable coordinates in a straightforward way like I thought.

 

Another idea is to dump the additional point data for each block into excel as coordinates based off of the block origin and adding that to my placement coordinates.  Any search terms for what that may be called?

0 Likes
Message 4 of 5

brandon_harper
Participant
Participant

Awesome! After some Google-fu I figured out to take all of my blocks and do dataextraction to an Excel file to get all of the extra point coordinates.  I then associate them with each block that has a secondary assembly point and use that to add or subtract to my base coordinate.

0 Likes
Message 5 of 5

Kent1Cooper
Consultant
Consultant

@brandon_harper wrote:

.... 

Is there a way using scripts to say "I want to insert this block on another blocks insertion point?" ....

 

Also, if this cannot be done with scripts but is possible with LISP, y'all have any resources for LISP code writing?  ....


Coincidentally, a similar question just came up -- for an example of a way to Insert a Block at the insertion point of another [in this case an Xref, but the same would work for a regular Block], using AutoLisp, with the routine finding the other one for you, see this thread.

 

On resources for AutoLisp code writing, Search this Forum for terms like "learn Lisp" and the like, and you'll find more suggestions, links, etc. than you'll know what to do with.

Kent Cooper, AIA
0 Likes