Author Topic: Sset Move and make basepoint 0,0  (Read 3532 times)

0 Members and 1 Guest are viewing this topic.

ML

  • Guest
Re: Sset Move and make basepoint 0,0
« Reply #15 on: December 06, 2007, 01:33:43 PM »

As Dec. suggested

This is working fine:

ThisDrawing.SendCommand "base" & vbCr & "0,0" & vbCr

Yes, i would prefer the setvariable method but, it is not big deal to send "A" command to the command line.

CmdrDuh

  • Automatic Duh Generator
  • King Gator
  • Posts: 4039
Re: Sset Move and make basepoint 0,0
« Reply #16 on: December 06, 2007, 01:34:45 PM »
It looks like you have to use a variant to set INSBASE
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second

CmdrDuh

  • Automatic Duh Generator
  • King Gator
  • Posts: 4039
Re: Sset Move and make basepoint 0,0
« Reply #17 on: December 06, 2007, 01:37:11 PM »
Code: [Select]
public sub SetInsBase()
Dim sysVarName As String
Dim sysVarData As Variant
Dim DataType As Integer
Dim arrayData3D(0 To 2) As Double
sysVarName = "INSBASE"
arrayData3D(0) = 1#: arrayData3D(1) = 1#: arrayData3D(2) = 0
sysVarData = arrayData3D    ' 3D array data
ThisDrawing.SetVariable sysVarName, sysVarData
end sub
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second

CmdrDuh

  • Automatic Duh Generator
  • King Gator
  • Posts: 4039
Re: Sset Move and make basepoint 0,0
« Reply #18 on: December 06, 2007, 01:38:08 PM »
I tested that at 1,1,0 and then 3,1,0 and it worked both times
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second

ML

  • Guest
Re: Sset Move and make basepoint 0,0
« Reply #19 on: December 06, 2007, 03:15:54 PM »

WOW!
I understand what is happening there but I think in this case I will stick with
ThisDrawing.SendCommand "base" & vbCr & "0,0,0" & vbCr

Just to keep it a bit cleaner

Good to know for future reference.

Thanks for the help CM!

M

Jeff_M

  • King Gator
  • Posts: 3944
  • C3D user & customizer
Re: Sset Move and make basepoint 0,0
« Reply #20 on: December 06, 2007, 03:21:22 PM »
As CmdrDuh shows, entering the value for INSBASE as a 3dpoint value it works. Why? Well, look at the definition in help:
Quote
Type: 3D-point
Saved in: Drawing
Initial value: 0.0000,0.0000,0.0000
Why does entering "0,0,0" work at the command line and not in VBA? Because the command line version does the conversion to a 3d point array for you. When operating with any 3d point in any program language, though, you must be the one to make sure to pass the data in the format it is expected to be.

HTH for any future items of a similar nature....such as when you insert a block using InsertBlock....you wouldn't use "1,1,0" as the insertion point, would you? And just like the initial portion of this thread, you specify a true 2d/3d point to move from/to and not the string version of it.

ML

  • Guest
Re: Sset Move and make basepoint 0,0
« Reply #21 on: December 06, 2007, 03:33:39 PM »

Hey Jeff

I totally understand what you are saying.
God, look at the posts we did on Raster Images; plenty of info on that subject.
I really actually learned a real lot from that post.

I was not doubting CM for one sec and I understand why it is done like that; it is just that I needed a quick down and dirty macro for this project that I may or may not use again.

However, I will keep that bit of code around for future use.

Mark


ML

  • Guest
Re: Sset Move and make basepoint 0,0
« Reply #22 on: December 06, 2007, 03:37:28 PM »

Ok,

I did put that code in and it works great!

Thanks CM - Jeff!

Mark

ML

  • Guest
Re: Sset Move and make basepoint 0,0
« Reply #23 on: December 06, 2007, 04:02:12 PM »

Actually
Those 8 lines of code can do the same thing with 3 lines.
The critical part was getting the 3 points into the variable.

Mark


Code: [Select]
Dim Basepnt(0 To 2) As Double

Basepnt(0) = 0#: Basepnt(1) = 0#: Basepnt(2) = 0#
ThisDrawing.SetVariable "INSBASE", Basepnt

ML

  • Guest
Re: Sset Move and make basepoint 0,0
« Reply #24 on: December 06, 2007, 04:06:59 PM »

Here is the whole thing if anyone is interested:

Mark

Code: [Select]
Sub MoveSsettoZeroZero()
 
 On Error Resume Next
 ThisDrawing.SelectionSets.Item("Sset1").Delete

 Dim Sset As AcadSelectionSet
 Dim Obj As AcadObject
 Dim Pnt As Variant
 Dim ZeroZero(0 To 2) As Double
   
 ZeroZero(0) = 0: ZeroZero(1) = 0: ZeroZero(2) = 0
 
 Set Sset = ThisDrawing.SelectionSets.Add("Sset1")
 Sset.SelectOnScreen
 'Debug.Print "Selection Set " & "("; Sset.Name; ")" & " was created"
 
 Pnt = ThisDrawing.Utility.GetPoint(, "Pickpoint")
 'Debug.Print "Point = "; Pnt(0) & " , " & Pnt(1)
 
 For Each Obj In Sset
  Obj.Move Pnt, ZeroZero
 Next Obj
 
 Dim Basepnt(0 To 2) As Double
 Basepnt(0) = 0#: Basepnt(1) = 0#: Basepnt(2) = 0#
 ThisDrawing.SetVariable "INSBASE", Basepnt
 
 ThisDrawing.SelectionSets.Item("Sset1").Delete
 
End Sub



Jeff_M

  • King Gator
  • Posts: 3944
  • C3D user & customizer
Re: Sset Move and make basepoint 0,0
« Reply #25 on: December 06, 2007, 04:18:44 PM »
Code: [Select]
Dim Basepnt(0 To 2) As Double

Basepnt(0) = 0#: Basepnt(1) = 0#: Basepnt(2) = 0#
ThisDrawing.SetVariable "INSBASE", Basepnt
To shorten it further, when you dimension your variable as a Double, the default value for a Double is 0. SO this could be written as
Code: [Select]
Dim Basepnt(0 To 2) As Double

ThisDrawing.SetVariable "INSBASE", Basepnt
However, while this CAN be done it is usually preferable to show the true intent, as you have done. Just an FYI.

ML

  • Guest
Re: Sset Move and make basepoint 0,0
« Reply #26 on: December 06, 2007, 04:22:46 PM »

Cool

That is good to know, thanks Jeff!
I agree though, it is good to have the true intent incase it needs to be adjusted above 0 later

Thanks

Mark