TurboCAD Forums

The Ultimate Resource for TurboCAD Knowledge

Register
 
Remember to do a search before you ask a question!!!

Changing a layer name in VBScript
Read 1216 times
* July 27, 2015, 09:58:56 PM
Sorry about all the questions lately, but am just finding my way back into some programming using VBScript in animation lab and am trying to find out a number of things some of which Andy has already pointed me in the direction of but for now I need to find out how to change an existing layer name in VBScript and also get a list of existing layers.

I have sussed out how to create a new layer and also how to delete a layer in VBScript but have not sussed out how to rename an existing layer or how to get a list of all the layers in the drawing.

Any help appreciated.

Thank You!

With so much to backtrack over, it would be really handy if all the snippets that people find were put in a pdf file that could be added to and updated by the contributors and some of the programmers on the forum as there are lots of snippets out there and no doubt some of them will give an outline of some of the routines to others developing scripts.


Logged


* July 27, 2015, 10:25:59 PM
#1
I have noticed that Andy has started to put snippets in a wiki he has created, and no doubt when we have somewhere to put them and index them we will start to move forward.

Starting the wiki is no small task and Andy will have a hard time of it no doubt but it will pay us all to have a reference to basic routines and syntax for various objects and how to access their properties.

Because I have only just started back on the programming, I have been brushing up on my regular expression searches and no doubt in a week or two should be able to pull all the routines mentioned in the sdk help files out into a list that may help in relation to an index for the wiki.

Good luck Andy, I am definitely on your side with this project !.
« Last Edit: July 28, 2015, 09:44:11 AM by Orion20036 »

Logged


* July 27, 2015, 11:55:16 PM
#2
Just done a regular expression search of the animation lab folder and found a function hidden away that I think Animation lab must use for iterating through the properties of objects in the drawing in order to implement the "SetPropertyValue" command, which I have yet to fathom but it looks as though it might be handy.

' From(0) To(-) Property\SetPropertyValue(FFFF) PropertyName("PenColor") PropertyValue(1)
function RunCustomCommand(Gr,commandStr, nCount, StAniEditor)
Dim propName, propValue, retVal, prop
retVal = GetErrorString(ERR_COMMANDSYNTAXERROR, commandStr)
if nCount <> 4 then exit function
propName = ""
propValue = 1
on error resume next
Err.Clear
call GetParameterN(commandStr,1, propName)
if propName = "" then
 retVal = retVal
 exit function
end if

Err.Clear
Dim bPSM
bPSM = false
set prop = Gr.Properties(CStr(propName))
if prop is nothing then
   set prop = Gr.Properties(CStr("%$SYMBOLPARAMETER"))
   if ( not prop is nothing) then
      bPSM = true
   else
      Alert retVal & vbcrlf & CStr(propName) & " - No such property"
      'RunCustomCommand = retVal
      Err.Clear
      exit function
   end if
end if

call GetParameterN(commandStr,2, propValue)
if IsEmpty (propValue) then
   set prop = nothing   
   exit function
end if
if bCheckScenarioMode  = false then
   if ((StepNum >= From1) and (StepNum <= To1))  then
      if (bPSM) then
         Dim bres
         bres = SetProperty (Gr, CStr(propName), propValue)
         if (bres = true) then
            Gr.Update
         else
            Alert "No such property"
         end if
      else
         prop.Value = propValue      
      end if
   end if
end if
set prop = nothing   

end function

Logged