Author Topic: Select object when created  (Read 1229 times)

Pearco

  • Hero Member
  • *****
  • Posts: 830
Select object when created
« on: April 22, 2015, 03:01:10 AM »
Macro Experts:
I have a macro that will draw and insert a base cabinet tray in  a shop elevation drawing and I would like it to be selected when created for additional insert locations without having to run the macro again. As I have it now,it only selects the last object. I know I can turn it on and off manually, but I want the Macro to do it.
Any ideas?
Jim
User since ProDesign 1.5

prl

  • Hero Member
  • *****
  • Posts: 3389
  • A Bézier Extrusion
Re: Select object when created
« Reply #1 on: April 22, 2015, 03:54:40 AM »
Jim, you want to insert it manually several times repeatedly, in essence pasting it here, there, etc?

 I'll add some code to put it on the clipboard.  Where do you want the insertion point?

Pearco

  • Hero Member
  • *****
  • Posts: 830
Re: Select object when created
« Reply #2 on: April 22, 2015, 07:55:17 AM »
prl;

The macro sets the insertion point at the Opening SetPoint command. It is the lower  left hand corner of the tray. The cabinet is already on the screen,so select all selects every thing. 

Jim
User since ProDesign 1.5

prl

  • Hero Member
  • *****
  • Posts: 3389
  • A Bézier Extrusion
Re: Select object when created
« Reply #3 on: April 22, 2015, 08:39:56 AM »
Jim, looking over your code, you have several undefined variables.

leftstile
Toespace
Bottomrail
Trayheight

Your defining these somewhere before this routine?

Pearco

  • Hero Member
  • *****
  • Posts: 830
Re: Select object when created
« Reply #4 on: April 22, 2015, 11:24:17 AM »
prl;

There are only two variables Trayheight and ArchHump whitch are hard coded in. The others are variables that help to define and draw the cabinet face frame. The procedure is as follows,
I first run the macro that creates the Base cabinet, then rum the tray macro. The ones you mention are a part of the base cab macro.
When I first wrote the tray macro, it was a part of the base cab macro. There was a if statement, shelves or trays.
I took it out to use else where, so it appears they are not needed now.
Jim
User since ProDesign 1.5

JJG

  • Hero Member
  • *****
  • Posts: 717
Re: Select object when created
« Reply #5 on: April 22, 2015, 12:08:43 PM »
the way it is possible without using the clipboard :

Code: [Select]
' Base Trays
' 12-25-14
' by Jim

Initiallayer=sys(3) ' store active layer

' Set Info box out of the way

Sys(130) = 400
Sys(131) = 400

Input " Enter tray width ?", Width
Traywidth = Width

' Set up variables
' Sys(242) = 1 not necessary here

>Setstartpoint
{
}

TrayHeight= 2.5

ArchHump=.5

sys(3)=999 'draft layer


>Ortholine 'left side
{

<Pointxyz [x1+leftstile],[Y1+(Toespace+BottomRail)]
<Pointxyz [xi+Leftstile],[Y1+(Toespace+Bottomrail+Trayheight)]
}

>Ortholine 'Bottom
{
<pointxyz [x1+leftstile],[Y1+(Toespace+BottomRail)]
<pointxyz [x1+Traywidth],[Y1+(Toespace+BottomRail)]
}

>Ortholine 'Left side top
{
<pointxyz [x1+Leftstile],[Y1+(Toespace+Bottomrail+Trayheight)]
<pointxyz [x1+(Traywidth/3)],[y1+(Toespace+Bottomrail+Trayheight)]
}

>Arc3 'Arc
{
<pointxyz [x1+Leftstile+(Traywidth/3)],[y1+((Toespace+Bottomrail)+(Trayheight))]
<Pointxyz [x1+Leftstile+(Traywidth/2)],[y1+((Toespace+Bottomrail)+(Trayheight-.5))]
<pointxyz [x1+Leftstile+((Traywidth/3)*2)],[y1+(Toespace+Bottomrail+Trayheight)]
}

>Ortholine 'Right side top
{
<pointxyz [x1+Leftstile+((Traywidth/3)*2)],[y1+(Toespace+Bottomrail+Trayheight)]
<pointxyz [x1+Leftstile+Traywidth],[y1+(Toespace+Bottomrail+Trayheight)]
}

>Ortholine 'Right side
{
<Pointxyz [x1+Traywidth],[Y1+(Toespace+Bottomrail+Trayheight)]
<Pointxyz [x1+Traywidth],[Y1+(Toespace+BottomRail)]
}

' Sys(242) = 0  not necessary here

>SelectLayer
{
  <Layer 999
  }
>groupDefine
{
  }

sys(3)=Initiallayer 'restore initial layer

>Applylayer
{
  }

End


Note it is possible to add a handle for copy, such as

>SetHandle
{
  <PointXYZ [Sx,Sy,Sz]
  <PointXYZ [Tx,Ty,Tz]
  <PointXYZ [Ux,Uy,Uz]
  }
after groupDefine-command.

 ;)

prl

  • Hero Member
  • *****
  • Posts: 3389
  • A Bézier Extrusion
Re: Select object when created
« Reply #6 on: April 22, 2015, 12:24:44 PM »
I took it out to use else where, so it appears they are not needed now.

Hmm, you are lucky BasicCAD doesn't initialize the variables to zero and you are at risk doing it your way. 

Regarding the multiple copies, if I were repeatedly pasting (inserting) a created part, in the macro after creating the part, I would select the part, set the handle where I want it and then copy it to the clipboard.  At that point you can paste as many copies as you want and the pasted copies will go where you insert them.  If this is what you are trying to achieve, let me know and I will amend your code.
« Last Edit: April 22, 2015, 12:26:37 PM by prl »

Pearco

  • Hero Member
  • *****
  • Posts: 830
Re: Select object when created
« Reply #7 on: April 23, 2015, 10:26:53 AM »
Thanks prl and JJG;

I ended up by moving the Traywidth variable to before the SetPoint command and looped the body of the macro with an if then statement and a goto if another tray is needed . Now I can insert many trays in the cabinet by only calling the macro once and setting the Setpoint where it is needed. If I continue trying to code different things, I may reach all the way up to rank of absolute beginner.

My only training in programming was old line basic, a dab of QB 4.5 and 1 semester of VB6. But I enjoy doing it.

Thanks again Guys.
Jim
User since ProDesign 1.5