Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Switch to another drawing during a VBA application session

  1. #1
    Member
    Join Date
    2017-10
    Location
    Inverness, Scotland
    Posts
    6
    Login to Give a bone
    0

    Thumbs up Switch to another drawing during a VBA application session

    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.

  2. #2
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,397
    Login to Give a bone
    0

    Default Re: Switch to another drawing during a VBA application session

    Have you thought of using xref's to align the parts?
    C:> ED WORKING....

  3. #3
    Member
    Join Date
    2017-10
    Location
    Inverness, Scotland
    Posts
    6
    Login to Give a bone
    0

    Default Re: Switch to another drawing during a VBA application session

    Quote Originally Posted by Ed Jobe View Post
    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.

  4. #4
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,397
    Login to Give a bone
    0

    Default Re: Switch to another drawing during a VBA application session

    Quote Originally Posted by arjenbroens757402 View Post
    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?
    C:> ED WORKING....

  5. #5
    Member
    Join Date
    2017-10
    Location
    Inverness, Scotland
    Posts
    6
    Login to Give a bone
    0

    Default Re: Switch to another drawing during a VBA application session

    Quote Originally Posted by Ed Jobe View Post
    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.

  6. #6
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,397
    Login to Give a bone
    0

    Default Re: Switch to another drawing during a VBA application session

    Quote Originally Posted by arjenbroens757402 View Post
    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.
    C:> ED WORKING....

  7. #7
    Member
    Join Date
    2017-10
    Location
    Inverness, Scotland
    Posts
    6
    Login to Give a bone
    0

    Default Re: Switch to another drawing during a VBA application session

    Quote Originally Posted by Ed Jobe View Post
    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.

  8. #8
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,397
    Login to Give a bone
    0

    Default Re: Switch to another drawing during a VBA application session

    Quote Originally Posted by ArjenB View Post
    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.
    C:> ED WORKING....

  9. #9
    Member
    Join Date
    2017-10
    Location
    Inverness, Scotland
    Posts
    6
    Login to Give a bone
    0

    Default Re: Switch to another drawing during a VBA application session

    Quote Originally Posted by Ed Jobe View Post
    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

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

  10. #10
    Active Member
    Join Date
    2012-11
    Location
    Italy
    Posts
    65
    Login to Give a bone
    0

    Default Re: Switch to another drawing during a VBA application session

    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

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 0
    Last Post: 2014-11-14, 02:11 AM
  2. Replies: 0
    Last Post: 2014-11-13, 11:10 PM
  3. Toolbar Drawing switch.
    By Wish List System in forum AutoCAD Wish List
    Replies: 2
    Last Post: 2013-02-25, 04:54 AM
  4. How to open a drawing from Windows Application?
    By CornDawgPower in forum VBA/COM Interop
    Replies: 6
    Last Post: 2011-07-08, 08:00 PM
  5. Drawing Walk - a drawing browser CUI application
    By zoomharis in forum AutoCAD Customization
    Replies: 10
    Last Post: 2007-03-20, 10:45 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •