Pulsonix User Forum

Technical advice from Pulsonix engineers and the wider community.

Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Help with using Pulsonix
 Scripting
 Setting component positions in PCB Design
Author Previous Topic Topic Next Topic  

rabryan

USA
3 Posts

Posted - 19 Sep 2014 :  11:20:14  Show Profile  Reply with Quote
I'm trying to automate the placement of certain components' positions in the PCB Design editor via javascript. I've tried assigning the Position.X and Position.Y attributes of the component directly with a float as well as trying to set them with the Design.toDSU() function, but neither seem to have any effect. Has anyone been able to assign positions to pcb components? Below is the full code. Also, is there a log or console anywhere that shows any output from the running of the script?


var Design = ActiveDocument();
var DesignComps = Design.Components();
var Comps = new Enumerator(DesignComps);



// Spin through the list of components.
for (; !Comps.atEnd(); Comps.moveNext()) {

    // Retrieve the current component.
    var Comp = Comps.item();
    Comp.Position.X = Design.ToDsuX(0.0);
    Comp.Position.Y = Design.ToDsuY(0.0);
    // Have also tried this
    //Comp.Position.X = 0;
    //Comp.Position.Y = 0;
}


psxforum

United Kingdom
66 Posts

Posted - 19 Sep 2014 :  12:07:41  Show Profile  Reply with Quote
Sadly, what you are trying to do is not currently possible. Contrary to what it says for data type 'Point' (that X and Y have both Get and Set functions), you will find on the page for DesignItem (the base class of most design objects) that the Position property has a 'Get' but no 'Set' function. This means that for items like components you can get the current position but you cannot change it.

David.
Go to Top of Page

rabryan

USA
3 Posts

Posted - 19 Sep 2014 :  12:34:20  Show Profile  Reply with Quote
Hi David. Thanks for the quick reply. Is there any other way to set position data for a large number of components outside of scripting? We have 60 led and resistors we're placing in a circular pattern. Just to change the radius of the circle, we have to: computer x,y coordinates from radius,angle in excel; click through each led/resistor pair and set the coordinates through the dialog. Perhaps there a text format such that we could copy it to the clipboard and then do an "apply layout to selected" operation?
Go to Top of Page

psxforum

United Kingdom
66 Posts

Posted - 19 Sep 2014 :  12:48:02  Show Profile  Reply with Quote
If you are placing items in a circular pattern, I would suggest you investigate Polar grids if you haven't already done so. A grid (for snapping items onto) usually gives you straightforward X Y steps, but by setting a grid as Polar you can tell it to start from a given location and subdivide the circle around that point by the required angular step, and also apply a number of concentric rings. It will also auto-rotate components as you place them at intersection points on the grid.

As things stand in the current software, there isn't really any way to feed the application with a list of component positions and angles

David
Go to Top of Page
  Previous Topic Topic Next Topic  
Jump To: