Results 1 to 6 of 6

Thread: Script File to Write Object Data

  1. #1
    Member
    Join Date
    2017-10
    Posts
    7
    Login to Give a bone
    0

    Default Script File to Write Object Data

    Hi,



    I have a database containing object information. I am able to write out a script from my database that inserts blocks into Autocad C3D. Here is an example of the script file:

    Code:
    osmode
    0
    -layer
    Set
    "2020_DESIGN"
    
    
    
    ATTREQ 1
    ATTDIA 0
    -insert
    "DESIGN"
    607476.547,7574318.945,0 1 1 0
    GAS
    GR04L001
    10354
    Is there a way that I can also insert Object Data (into a data table) using this script when creating the block?



    I have attached an image showing the structure of the data table that I would like to populate.



    Thanks in advance



    Lee
    Attached Images Attached Images

  2. #2
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,096
    Login to Give a bone
    0

    Default Re: Script File to Write Object Data

    Can your database create a shp file? If so, you can use the MAPIMPORT command, which will allow you to insert AutoCAD Blocks with attached object data.

    There maybe other file formats that will do similar, but I am not familiar with them.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  3. #3
    Member
    Join Date
    2017-10
    Posts
    7
    Login to Give a bone
    0

    Default Re: Script File to Write Object Data

    Can your database create a shp file? If so, you can use the MAPIMPORT command, which will allow you to insert AutoCAD Blocks with attached object data.
    Not at the moment, I have found some code from Ross Pickard to write Shapefiles which I am trying to integrate - the downfall is that it needs all users to have Ross's DLL's registered on each machine.

    I still do not have Ross' code working and am hoping I can still just write out a .SCR file.

  4. #4
    Woo! Hoo! my 1st post
    Join Date
    2019-06
    Posts
    1
    Login to Give a bone
    0

    Default Re: Script File to Write Object Data

    I think this code will help you Script File to Write Object Data

    Test-Path
    Test-Path is one of the more well-known commands when you start working with files. It allows you to test for a folder or a file before you try to use it.

    If( Test-Path -Path $Path )
    {
    Do-Stuff -Path $Path
    }
    Split-Path
    Split-Path will take a full path to a file and gives you the parent folder path.

    PS:> Split-Path -Path 'c:\users\kevin.marquette\documents'
    c:\users\kevin.marquette
    If you need the file or folder at the end of the path, you can use the -Leaf argument to get it.

    PS:> Split-Path -Path 'c:\users\kevin.marquette\documents' -Leaf
    documents
    Join-Path
    Join-Path can join folder and file paths together.

    PS:> Join-Path -Path $env:temp -ChildPath testing
    C:\Users\kevin.marquete\AppData\Local\Temp\testing
    I use this anytime that I am joining locations that are stored in variables. You don’t have to worry about how to handle the backslash becuse this takes care of it for you. If your variables both have backslashes in them, it sorts that out too.

    Resolve-Path
    Resolve-Path will give you the full path to a location. The important thing is that it will expand wildcard lookups for you. You will get an array of values if there are more than one match.

    Resolve-Path -Path 'c:\users\*\documents'

    Path
    ----
    C:\users\kevin.marquette\Documents
    C:\users\Public\Documents

  5. #5
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,096
    Login to Give a bone
    0

    Default Re: Script File to Write Object Data

    Quote Originally Posted by ananyagupta1214783266 View Post
    I think this code will help you Script File to Write Object Data

    Test-Path
    Test-Path is one of the more well-known commands when you start working with files. It allows you to test for a folder or a file before you try to use it.
    I'm not certain Powershell is the correct form of scripting being requested here, nor have I seen Powershell interact with drawing data.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  6. #6
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,096
    Login to Give a bone
    0

    Default Re: Script File to Write Object Data

    If you already have a database, maybe you can use ODBC to connect to it using the Data Connect palette of Map 3D.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

Similar Threads

  1. 2014: Added object data fields to Polyline, but object data is empty or zero
    By tntdraftsol in forum AutoCAD Map 3D - General
    Replies: 6
    Last Post: 2015-07-24, 12:20 PM
  2. File write problem with NWD- /NWC-file type
    By bma in forum NavisWorks - General
    Replies: 3
    Last Post: 2010-08-31, 09:43 PM
  3. Replies: 0
    Last Post: 2009-04-15, 02:42 PM
  4. Replies: 10
    Last Post: 2007-10-09, 01:11 PM
  5. Write a script using Express Tools command LMan
    By gis.68227 in forum AutoCAD Customization
    Replies: 7
    Last Post: 2004-08-06, 04:33 PM

Posting Permissions

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