Author Topic: Scripted placement of Rooms?  (Read 3046 times)

0 Members and 1 Guest are viewing this topic.

Offline mrpacketheadTopic starter

  • Super Contributor
  • ***
  • Posts: 2845
  • Country: nz
  • D Size Cell
Scripted placement of Rooms?
« on: July 15, 2015, 09:11:38 pm »
Hello to probably the best support of Altium on the planet.

I'm mid designing a project where I have hundreds of the same circuit segment to place on some complex shaped pcbs.  The pcb shapes where design in auto-cad and the component positioing is extracted out of that, and i get X,Y and rotation data in a text file.    I've been able to to extract that position data and move components around the board and get them in the correct place.   In the instance below, i read in a file that has the designators of a bunch of components, and then move them to the x,y specified point.     A big time saving..

I'd like to be able to do the same for an entire room of components though.. Does anyone know if you can move rooms in the same manner. I'm sure you can, i'm just not sure what its called.







Const ForReading = 1
' on mac generated .csv files run
' tr '\15' '\n' < coords.csv
' to fix end of line delimiters

Dim Board
Dim xCoord
Dim yCoord
Dim Angle
Dim Designator

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("W:\nfatonion_altium\coords.csv", ForReading)

' Load current board
    If PCBServer Is Nothing Then
        ShowMessage("Not a PCB or footprint editor activated.")
    End If

    Set Board = PCBServer.GetCurrentPCBBoard

    If Board Is Nothing Then
        ShowMessage("Not a PCB or footprint loaded.")
        'End
    End If

    Call PCBServer.PreProcess

    Do Until objFile.AtEndOfStream
        strLine = objFile.ReadLine
        strLine = replace(strLine,"\15", ",")
        arrFields = Split(strLine, ",")

        Designator = arrFields(0)

        Dim Comp
        Set Comp = Board.GetPcbComponentByRefDes(Designator)
        If Comp Is Nothing Then
        ShowMessage("No Designator :"+designator)
        Call PCBServer.PostProcess
        End If

        Call PCBServer.SendMessageToRobots(Comp.I_ObjectAddress, c_Broadcast, PCBM_BeginModify , c_NoEventData)


        xCoord = arrFields(n+1)
        yCoord = arrFields(n+2)
        Angle = arrFields(n+3)

        Comp.X = Board.XOrigin + MMsToRealCoord(xCoord)
        Comp.Y = Board.YOrigin + MMsToRealCoord(yCoord)
        Comp.Rotation = Strtofloat(Angle)

        Call PCBServer.SendMessageToRobots(Comp.I_ObjectAddress, c_Broadcast, PCBM_EndModify , c_NoEventData)


Loop
Call PCBServer.PostProcess
On a quest to find increasingly complicated ways to blink things
 

Offline free_electron

  • Super Contributor
  • ***
  • Posts: 8550
  • Country: us
    • SiliconValleyGarage
Re: Scripted placement of Rooms?
« Reply #1 on: July 15, 2015, 10:03:57 pm »
you do know that you can load a pick and place file right ?

tools - component placement- place from file ... 
Professional Electron Wrangler.
Any comments, or points of view expressed, are my own and not endorsed , induced or compensated by my employer(s).
 

Offline mrpacketheadTopic starter

  • Super Contributor
  • ***
  • Posts: 2845
  • Country: nz
  • D Size Cell
Re: Scripted placement of Rooms?
« Reply #2 on: July 16, 2015, 03:20:57 am »
you do know that you can load a pick and place file right ?

tools - component placement- place from file ...

No ,  thats a new one on me.   In my case, not sure if it would have helped,  i would have had to arrange my data into a suitable file, for it to have been read by altium,  either way, i'd have had to write some code/script to convert from one side to the other.

The big advantage of being able to move a room is that I can route one room out, then paste the routing format to the other ones..  Since i need to repeat this several hundred times, i'd love to be able to script the move. 
On a quest to find increasingly complicated ways to blink things
 

Offline free_electron

  • Super Contributor
  • ***
  • Posts: 8550
  • Country: us
    • SiliconValleyGarage
Re: Scripted placement of Rooms?
« Reply #3 on: July 16, 2015, 03:48:32 am »
room copy only works if the schematic is designed as multichannel
Professional Electron Wrangler.
Any comments, or points of view expressed, are my own and not endorsed , induced or compensated by my employer(s).
 

Offline mrpacketheadTopic starter

  • Super Contributor
  • ***
  • Posts: 2845
  • Country: nz
  • D Size Cell
Re: Scripted placement of Rooms?
« Reply #4 on: July 16, 2015, 04:40:30 am »
room copy only works if the schematic is designed as multichannel

Which it is. Thats not the problematic bit.      The problematic bit is moving named rooms to specific locations.
On a quest to find increasingly complicated ways to blink things
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf