View Full Version : Switch to another drawing during a VBA application session
ArjenB
2017-10-07, 02:07 PM
I'm building a VBA application that requires 3D (2D + Height) ID information from one drawing to be used in another one to ALIGN it.
In setting out we get snippets of a project drawing in a local coordinate system in mm. and need to manipulate (scale mm => M. and align to new coordinates) it into a Project Coordinate System (mostly flat OS) for production setting out in M..
I have two or more drawings open, collate at least 3 (2D + H) points in the overall PCS system drawing and align the other automatically to these 3 global points with ALIGN.
At the moment I'm running my application in 1 drawing, store the info, close my application, open the other drawing and run my application again to retrieve the stored info to align the drawing automatically.
It needs to run and use all other drawings to give the focus to on demand.
Any ideas are welcome.
Thanks.
Ed Jobe
2017-10-10, 02:48 PM
Have you thought of using xref's to align the parts?
ArjenB
2017-10-11, 05:23 PM
Have you thought of using xref's to align the parts?
Yep, but the drawing will get heavier and heavier and certainly not clearer when all is stacked up in the overall Construction Coordinate System drawing.
The ALINGed drawing is placed in a Total Station controller for setting out in the field. It doesn't have the same XREF facilities that AutoDESK products offer, I have to load drawings physically into one drawing instead of linked ones.
Ed Jobe
2017-10-13, 02:38 PM
Yep, but the drawing will get heavier and heavier and certainly not clearer when all is stacked up in the overall Construction Coordinate System drawing.
The ALINGed drawing is placed in a Total Station controller for setting out in the field. It doesn't have the same XREF facilities that AutoDESK products offer, I have to load drawings physically into one drawing instead of linked ones.
I don't use Total Station, so I'm not familiar with it, but as for xrefs getting "heavy", you can load/unload dwg's at will. You can also bind them when you get them the way you want.
With your current method, is the idea to get all info from all dwgs into one file?
ArjenB
2017-10-13, 04:31 PM
I don't use Total Station, so I'm not familiar with it, but as for xrefs getting "heavy", you can load/unload dwg's at will. You can also bind them when you get them the way you want.
With your current method, is the idea to get all info from all dwgs into one file?
No not in one file but in one and the same Coordinate system.
The XREF load/unloading is not a solution as the Total Station controller has a basic AutoDESK import feature which has not the functionality AutoDESK products have.
Hence the separation of files in the same coordinate system on the controller. To prevent sluggishness on my controller I split projects up in seceral sub-projects per drawing.
In construction a Total Station is used to project design points into the field and field situations (AsBuilts) back into the design to verify conformity and real clash detection before the next phase is built. The instrument and controller generates 3D coordinates in setting out (design projection in the field) and measurements (verification from field back into design) in a coordinate system therefore the drawings need to be in that coordinate system too.
Hope this clarifies my intent.
Ed Jobe
2017-10-13, 09:15 PM
Hope this clarifies my intent.
Not really. Perhaps you could post sample files and your code? It seems to me that what you describe is that you are trying to automate inserting object from separate files, "snippets of a project". It seems to me that you could try this manual process.
1. xref the snippets in. Assuming Total Station can export the points in dwg format.
2. align the points
3. bind the xrefs
4. explode the block. Now everything is in the same coord sys
5. wblock desired "snippets" back to individual files.
If you can come up with a similar workflow, then we can help you code it. I assume you are trying to use vba in AutoCAD, where you would have xrefs avaiable. As-is, if you can't define a workflow to do what you want, then you can't code it. You should be able to find a way to manually do what you want.
ArjenB
2017-10-14, 09:58 AM
Not really. Perhaps you could post sample files and your code? It seems to me that what you describe is that you are trying to automate inserting object from separate files, "snippets of a project". It seems to me that you could try this manual process.
1. xref the snippets in. Assuming Total Station can export the points in dwg format.
2. align the points
3. bind the xrefs
4. explode the block. Now everything is in the same coord sys
5. wblock desired "snippets" back to individual files.
If you can come up with a similar workflow, then we can help you code it. I assume you are trying to use vba in AutoCAD, where you would have xrefs avaiable. As-is, if you can't define a workflow to do what you want, then you can't code it. You should be able to find a way to manually do what you want.
Sorry guys,
We're going off topic here.
The question can I "Switch to another drawing during a VBA application session" ? is a simple No.
Thanks for your replies.
Ed Jobe
2017-10-20, 03:19 PM
Sorry guys,
We're going off topic here.
The question can I "Switch to another drawing during a VBA application session" ? is a simple No.
Thanks for your replies.
Yes you can, but until we know what process/workflow you are using we can't show you any code. The reason I asked you to try a manual process is so that I could know what you are trying to do. Then we can automate the manual process. This is similar to creating a flowchart of your code's execution. So far you have only explained what output you want without explaining how you intend to get there.
Each time you open a dwg it is added to the AcadApplication.Documents() collection and it becomes the ActiveDocument. When the ActiveDocument changes, is also set to ThisDrawing. So you can switch the ActiveDocument by assigning it a Document object from the Documents collection.
ArjenB
2017-10-21, 09:40 AM
Yes you can, but until we know what process/workflow you are using we can't show you any code. The reason I asked you to try a manual process is so that I could know what you are trying to do. Then we can automate the manual process. This is similar to creating a flowchart of your code's execution. So far you have only explained what output you want without explaining how you intend to get there.
Each time you open a dwg it is added to the AcadApplication.Documents() collection and it becomes the ActiveDocument. When the ActiveDocument changes, is also set to ThisDrawing. So you can switch the ActiveDocument by assigning it a Document object from the Documents collection.
Thanks Ed:
Intent: ALIGN Drawing B to the coordinate system of Base Drawing A (M. units, 2D transformation) in AutoDESK 2016 products or higher using VBA
Manual workflow:
Open Drawing A, collect 2 mutual (mutual in Drawing A and Drawing B, usually Grid line intersections) points with ID each side of the drawing and write them down.
Open Drawing B, ALIGN
=> point at mutual point 1, manually type in coordinates of point 1 in drawing A
=> point at mutual point 2, manually type in coordinates of point 2 in drawing A
=> discard the request for a 3rd point
=> scale the drawing (Y)
check the ALIGNED drawing on a third mutual point.
Automated workflow:
=(1)> Open Drawing A and B,
=(2)> Start application,
=(3)> Select Drawing A, point a 3 mutual points and save coordinates on the Clipboard
=(4)> Switch to Drawing B, point at 1st and 2nd mutual points in that drawing,
=(5)> Collect the points from the ClipBoard and execute the ALIGN command based on 1st and 2nd mutual points
=(6)> QC check: Place circles on all 3 mutual points from the ClipBoard
=(7)> End application
=(8)> carry out a visual check in ALIGNed drawing B
=(9)> Save this drawing with an OK- prefix to ensure the correct status (QC checked)
Italics in Step (4) is where the error occurs in AutoCAD 2016 and higher
Tried setting FIBERWORLD and NEXTFIBERWORLD to 1 prior to pointing does not stop the error from occurring.
I lack the knowledge if FIBERWORLD/NEXTFIBERWORLD have more options available, browsed the net but nothing.
RICVBA
2017-10-23, 06:35 AM
what if you have one drawing only at a time?
=(1)> Open Drawing A only
=(2)> Start application,
=(3)> in Drawing A, point a 3 mutual points and save coordinates on the Clipboard
=(4)> Close drawing A and open drawing B, point at 1st and 2nd mutual points in that drawing,
=(5)> Collect the points from the ClipBoard and execute the ALIGN command based on 1st and 2nd mutual points
=(6)> QC check: Place circles on all 3 mutual points from the ClipBoard
=(7)> End application
Ed Jobe
2017-10-24, 02:25 PM
Another option
Xref A into B, align, then detach A.
ArjenB
2017-10-24, 03:13 PM
what if you have one drawing only at a time?
=(1)> Open Drawing A only
=(2)> Start application,
=(3)> in Drawing A, point a 3 mutual points and save coordinates on the Clipboard
=(4)> Close drawing A and open drawing B, point at 1st and 2nd mutual points in that drawing,
=(5)> Collect the points from the ClipBoard and execute the ALIGN command based on 1st and 2nd mutual points
=(6)> QC check: Place circles on all 3 mutual points from the ClipBoard
=(7)> End application
Yep, will give that a try, see if it allows GetPoint swapping the only drawing in use.
I'll get back on that, thanks.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.