How to get a .pdf export in correct dimensions?

Hello!

Intro:
This is my very first (of many) post in this forum and it is about the issue that made me find this community.

A couple of years back I found a “digitizer” project online. (measuring arm)
I bought the encoders and downloaded the code but I didn’t get going there and then cause I wanted to scale it up first.
Finally started some weeks back now and I have the arm up and running! :slight_smile:
This is just a prototype, my final goal is 5 axis and export to 3D. However I really need this to work first and learn some things on the way. I have really learned a lot already and I really like processing!

The problem
When I have taken out my measurements and done the PDF file export things are not right.
First of all, In the code (that I downloaded and edited what I could) the scale is set to a value and I have no clue why this value is? (2,84832). It could be calculated from the creators device size and that is a lot smaller than my device!

When I open the PDF file exported I don’t see all my data. The sheet is to small or the size of the data to big.

I tried changing the scaling to “1” but this makes my measurements way off when I export the PDF to e DXF and opens in in my CAD software.

I need my PDF to come out in the correct size and scale as I have set my device measurements to.

The part of code I mention above (full code below)

 if (ctl_pdf.update())
  {
    String s="3D_"+Integer.toString(year())+"_"+Integer.toString(day())+"_"+Integer.toString(hour())+"_"+Integer.toString(minute())+"_"+Integer.toString(second())+".pdf";
    size(1600, 900);
    beginRecord(PDF, s); 
    background(255);
    translate(width/2, height/2);
    scale(2,84832);
    for (object obj : objects)
    {
      obj.export();
    }
    endRecord();
  }

Images:
This is my last PDF of a dot in the center of my device. Not right! The dot should be a small X in the middle of the document.

!
This is with scale set to “1”. Looks good but measurements is off!
!
This is just to show my environment. Image from a different day so the cross pattern is irrelevant.
!

Full code tab: GUI2_demo4_plus (I cant fit the other tabs in this post. There is: gui, objects and pointer tab. If they are interesting to see for the solution just say and Ill post them in the conversation below. Or you can get the original files here from the creator: https://github.com/dzlonline/3D_digitizer2/tree/master/processing_code/GUI2_demo4_plus)

//============================================================
//  3D Digitizer GUI V2 Prototype
//  Used with 3D digitizer:
//  http://fablab.ruc.dk/diy-digitizer/
//  (F)DZL 2015
//============================================================

import processing.serial.*;
import peasy.*;
import processing.pdf.*;

//============================================================
//-3D navigation
//============================================================
PeasyCam cam;

//============================================================
//-Digitizer
//============================================================
pointer digitizer = new pointer(this, 0);

//============================================================
//  GUI controls
//============================================================
ArrayList<control> controls = new ArrayList<control>();

control ctl_clear = new control(10, 10, 'q', "Clear", "Clear all");
control ctl_point = new control(10, 10+1*40, 'p', "Point", "Mark a point");
control ctl_circle = new control(10, 10+2*40, 'c', "Circle", "Mark a hole");
control ctl_feature = new control(10, 10+3*40, 'f', "Feature", "Start a feature. Use \"Modify\" to add points");
control ctl_modify = new control(10, 10+4*40, 'm', "Modify", "Modify last figure");
control ctl_pdf = new control(10, 10+5*40, 'z', ".pdf", "Export as flat PDF file");

//============================================================
//  Objects
//============================================================
ArrayList<object> objects = new ArrayList<object>();

//============================================================
//  Setup
//============================================================
void setup()
{
  size(1600, 900, P3D);

  //Set up visualizer
  cam = new PeasyCam(this, 750);
  cam.setMinimumDistance(50);
  cam.setMaximumDistance(1500);
  //Add GUI controls to display list
  controls.add(ctl_clear);
  controls.add(ctl_point); 
  ctl_point.typematic=true;
  controls.add(ctl_circle); 
  ctl_circle.typematic=true;
  controls.add(ctl_feature);
  controls.add(ctl_modify);
  ctl_modify.typematic=true;
  controls.add(ctl_pdf);

  background(0);
}

//============================================================
//  Handy globals
//============================================================
float penX=0;
float penY=0;
float penZ=0;
float penA=0;
//PVector pen;

object currentObject=null; //-Last created object

//============================================================
//  Draw
//======================================================proce======

void draw()
{
  //-Get coordinated from digitizer
  digitizer.update();    
  //-Update globals

  PVector pd=new PVector(digitizer.tip.x, digitizer.tip.y);
  penA=digitizer.rotation;

  pd.rotate(-penA);

  penX=pd.x;   
  penY=pd.y;
  penZ=digitizer.tip.z;
  //  pen=digitizer.tip;






  background(0);
  //-Draw pad
  stroke(255);
//  fill(10,10,10,128);
  noFill();
  rect(-277.5, -277.5, 277.5*2, 277.5*2);

  rotateZ(penA);

  //-Draw zero cross
  stroke(100, 100, 0);
  line(-20, 0, 20, 0);
  line(0, -20, 0, 20);
  //-Draw all objects flat projection
  for (object obj : objects)
  {
    obj.project();
  }
  //-Draw all objects
  for (object obj : objects)
  {
    obj.draw();
  }
  //-Draw cursor
  pushMatrix();
  rotateZ(-penA);
  translate(digitizer.tip.x, digitizer.tip.y, digitizer.tip.z);
  stroke(0, 255, 0);
  noFill();
  box(10);
  popMatrix();
  
  
  //-Draw Heads Up Display
  cam.beginHUD();  
  color faceColor=color(98, 206, 198);
  color textColor=color(75, 42, 0);
  stroke(50);
  fill(98, 206, 198);
  rect(width-115, 10, 105, 90);
  fill(75, 42, 0);
  textSize(15);
  //-Coordinates
  text("X: "+penX, width-110, 30);
  text("Y: "+penY, width-110, 50);
  text("Z: "+penZ, width-110, 70);
  text("R: "+penA, width-110, 90);
  pushStyle();
  //-Update GUI controls 
  if (ctl_clear.update())
  {
    objects.clear();
  }
  if (ctl_point.update())
  {
    currentObject=new gpoint(penX, penY, penZ);
    objects.add(currentObject);
  }
  if (ctl_circle.update())
  {
    currentObject=new gcircle(penX, penY, penZ);
    objects.add(currentObject);
  }
  if (ctl_feature.update())
  {
    currentObject=new gfeature(penX, penY, penZ);
    objects.add(currentObject);
  }
  if (ctl_modify.update())
  {
    if (currentObject!=null)
    {
      currentObject.modify(new PVector(penX, penY, penZ));
    }
  }
  if (ctl_pdf.update())
  {
    String s="3D_"+Integer.toString(year())+"_"+Integer.toString(day())+"_"+Integer.toString(hour())+"_"+Integer.toString(minute())+"_"+Integer.toString(second())+".pdf";
    size(1600, 900);
    beginRecord(PDF, s); 
    background(255);
    translate(width/2, height/2);
    scale(2,84832);
    for (object obj : objects)
    {
      obj.export();
    }
    endRecord();
  }
  //-Draw GUI controls
  for (control ctl : controls)
  {
    if (ctl.change)
      ctl.draw();
    if (ctl.mouseOver)
      ctl.drawHelp();
  }
  popStyle();
  cam.endHUD();
}
1 Like

Thanks for sharing a great project.

When you don’t change it, is everything working in your CAD software? In other words, does this all work except the PDF scaling?

1 Like

why where how?

1 Like

If I don’t change the scaling and just leave it at the number that is from the original code. Then I have no way of testing cause even just a point takes up the whole PDF file. And since I can’t seem to change the size of the PDF document I have no way of measuring anything since I can’t fit measurements on this document.

Yeah. The more I think about it I will probably just try to get dxf up and running directly.
I am trying the code from Bryan1 who is making a similar arm and has gotten a bit further with the export settings.

1 Like

sadly i not have your hardware skill set but

2 Likes

Wow!… Can I integrate this simulation with the code I already have for measuring?
Either side by side with the measuring code or replacing the current measuring graphics with this arm… That would be so cool!

I’ll try to test it out later tonight or tomorrow.

1 Like

would be nice if that exercise could be of any use,
WARNING in that version i change the name of the angles
original E0 E1 E2
my code E1 E2 E3 fit to key use [1][2][3] in MWPP


if you share the actual arduino code
? sending the 3 angles ? conti or at measuring points ?
i could implement that interface so the simulation follows the table arms.

1 Like

Hi
Sorry for my late answer!
I had so much at work so I havent had any time over for the fun stuff!

Here is the arduino code I use right now:
https://we.tl/t-GJcIgLUJIu

It would be super cool!
I am going to add more encoders to my next upgrade and that will be a whole different arm.
This arm is my learning project and proof that it will work.
If we get this to work we really have to make it for the upgrade to later? :slight_smile:

I havent designed the next arm so I cant say how far away it is but I just wanted to mention it. :slight_smile:

2 Likes

can try revision from here
when you move the mechanic arm manually
the processing show should follow ( untested )


what i miss in the whole concept is HOW IT SHOULD WORK

lets say there is a 3D ?object? terrain ? on the table
and you move the arm manually and touch the object
THEN something should happen

  • you press a arduino button
  • the arm tip has its own measuring push button
  • here now also could press the key [t] from the processing show

and then the record is stored to array ( and later on request key [e] exported to DXF )

just sending 10 lines per sec and have no ?connection? with the measuring object
can not be used. WHAT I MISS?

2 Likes

Oh, Im really exited to test that!
I will try to be home early this friday so I can focus on the arm…
(if I get any fee time before this is number one thing to test out.)

I will send you my processing code so you can see.
I move the arm manually to a point then I can press different buttons to draw and record (I guess) my points position. When I have all my points, lines and circles I can export to DXF, point cloud or PDF.

1 Like

Hi
Here is the complete processing code made by bryan1 and edited some to fit my needs.
https://we.tl/t-XGi04oZJTl

Here is a screenshot of how the interface loks today with the different capture points options.

I tried loading the code at the bottom of the article on your page… Looks awesome.
So cool if the animated arm would follow the real arms movement.

2 Likes

Ahh its nice when you can find someone that can use their programming Foo and turn out a beautiful interface like KLL has. My arm has progressed to a 5 DOF system.

The Arduino code I am currently running sends the Cartesian coordinates of each point in the arm, as well in addition to the end effector (end point). I have uploaded the current work in progress code for both the Arduino and Processing to my GitHub repository.

3 Likes

kll, The 5-DOF arm project is complete that I believe Teljemo had/has been talking with me about for his 4-DOF arm. Is there any way to adapt the interface you put together for the 4-DOF arm with this enhanced version?
I have each of the pivot points being sent directly to processing by the Arduino, so there is no math involved in calculating, its all done in the Arduino


2 Likes