Jump to content

Help to translate from VBA to VBscript

VBA VBscript

4 replies to this topic

#1 subzero.tis@tiscali.it


  • Members
  • Pip
  • 1 posts

Posted 14 March 2019 - 10:52 PM

Hi Everyone,
I'm trying to translate a VBA MAcro to VBscript and I have some problems.
I check every entity in ModelSpace if is a AcDbBlockReference then I check if it has HasAttributes and then and so on but when I want to know the position of this block by
   ThisDrawing.Utility.Prompt ObjRef.InsertionPoint(0)
I have an error

For c = 0 To ThisDrawing.ModelSpace.Count - 1
   Set ent = ThisDrawing.ModelSpace.Item(c)
   ThisDrawing.Utility.Prompt ent.ObjectName
   If (ent.ObjectName = "AcDbBlockReference") Then
	  Set ObjRef = ThisDrawing.ModelSpace.Item(c)
	  If ObjRef.HasAttributes Then
		 AttList = ObjRef.GetAttributes
		 Valori.JOB  = AttList(0).TextString
		 Valori.DWG  = AttList(1).TextString
		 Valori.MAT  = AttList(5).TextString
		 Valori.QTY  = AttList(6).TextString

		ThisDrawing.Utility.Prompt ObjRef.InsertionPoint(0)
	  End If
   End If

So where I can find all this information?
thnak you

#2 Hellen_V

    nanoCAD Team

  • Members
  • PipPipPip
  • 701 posts

Posted 15 March 2019 - 08:24 AM

View Postsubzero.tis@tiscali.it, on 14 March 2019 - 10:52 PM, said:

Hi Everyone,
you should better contact Developers' Club with your question: http://developer.nanocad.com
Go for nanoCAD Plus 10 now!
New interface, improved and accelerated drawing process, support for dwg2018 format. You will like new version!
Free trial license is available here: https://nanocad.com/.../plus/download/

nanoCAD Support Team

#3 Ivano Rossi


  • Members
  • Pip
  • 3 posts

Posted 15 March 2019 - 04:44 PM

That's incredible for insert a block you can use the exaclty same code from VBA
Dim InsertionPoint(3)
InsertionPoint(0) = 0
InsertionPoint(1) = 0
InsertionPoint(2) = 0
Block = "blockname"
Xscale = 1.0
Yscale = 1.0
ZScale = 1.0
Rotation = 0.0
ThisDrawing.ModelSpace.InsertBlock InsertionPoint, Block, Xscale, Yscale, ZScale, Rotation
but to know InsertionPoint from an existing block in the drawing InsertionPoint generate an error ...

#4 Ivano Rossi


  • Members
  • Pip
  • 3 posts

Posted 16 March 2019 - 05:04 PM

with this code
Set Obj = ThisDrawing.ModelSpace.Item(0)
ThisDrawing.Utility.Prompt Obj.ObjectName
if (IsArray(Obj.InsertionPoint)) then
	ThisDrawing.Utility.Prompt "IsArray"
	ThisDrawing.Utility.Prompt ubound(Obj.InsertionPoint)
	ThisDrawing.Utility.Prompt "NOT Array"
end if

I have this response
Obj.ObjectName AcDbBlockReference
IsArray true
ubound 2
so how can I take the value of Obj.InsertionPoint(0) and Obj.InsertionPoint(1) if this generate an error?W TO TAKE A PROPERTY WHERE IS AN ARRAY?how to take a
Property value where the Property ia an array?

#5 Ivano Rossi


  • Members
  • Pip
  • 3 posts

Posted 23 March 2019 - 10:08 PM

The solution

Dim pnt
pnt = ThisDrawing.Utility.CreateSafeArrayFromVector(Obj1.InsertionPoint)

ThisDrawing.Utility.Prompt pnt(0)
ThisDrawing.Utility.Prompt pnt(1)
ThisDrawing.Utility.Prompt pnt(2)

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users