Jump to content

How can I make this insert at the right scale?


BLOACH85

Recommended Posts

Hey im still working on this lisp routine! It works fine now but i need it to insert @ the right dimscale the vla-setautoscale did not work. what else can i do? will vla-setscale?

 

(defun C:STUBS2 (/ col count dis pt row strdis tb va vm vo)
 (setq pt (vlax-3d-point (getpoint "\nPick Insertion Point: ")))
 (setq vo (vlax-get-acad-object))
 (setq va (vla-get-activedocument vo))
 (setq vm (vla-get-modelspace va))
 (setq row 16)
 (setq col  1)
 (setq dis (getdist "\nWhat Is The First Stub Dimension? : "))
 (if (not (vl-string-search "" (setq strdis (rtos dis 4 4))))
     (setq strdis (strcat strdis "")))
 (setq tb (vla-addtable vm pt row col 1 1))
 (vla-put-titlesuppressed tb :vlax-false)
 (vla-put-headersuppressed tb :vlax-true)
 (vla-put-RegenerateTableSuppressed tb :vlax-true)
 (vla-put-vertcellmargin tb 0.1)
 (vla-put-horzcellmargin tb 0.25)
 (vla-setrowheight tb 0 0.3875)
 (vla-setcolumnwidth tb 0 2.4)
 
 (vla-settextstyle tb actitlerow "bold");title text style
 (vla-settextstyle tb acdatarow "Standard");data rows text style
 (vla-settextheight tb actitlerow 0.27);title text height = 0.27
 (vla-settextheight tb acdatarow 0.21);other cells text height = 0.21
 (vla-setalignment tb actitlerow acmiddlecenter);title alignment
 (vla-setalignment tb acdatarow acmiddlecenter);data cell alignment
 (vla-setformat tb acdatarow "arch");data cell format
 (vla-settext tb 0 0 "STUBS");title text
 
 (setq count 1)
 
 (while (< count row)
(vla-setcelltextstyle tb count 0 "Standard")  
 (vla-setcelldatatype tb count 0 acdouble acunitdistance);optional  
 (vla-setrowheight tb count 0.3875)
 (if (=  count 1)
 (vla-settext tb count 0 strdis)    
 (vla-settext tb count 0 (strcat "= A2*" (itoa count))))
 (setq count (1+ count)))
 (vla-put-RegenerateTableSuppressed tb :vlax-false)
 
 (princ)
 );_ end

Link to comment
Share on other sites

  • Replies 51
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    24

  • BLOACH85

    21

  • fixo

    7

Top Posters In This Topic

Yes it is Im just getting irritated with every solution that i can think of. I tried (vla-setscale tb (getvar "dimscale"))

and other arrangements but all came out with same statement on command prompt too few actual parameters! so i dont know like i say this i s my first routine ive worked on using vla format so i dont know all of the basics yet. so do you know what to do?

 

(defun C:ST2(/ col count dis pt row strdis tb va vm vo)
 
 (setq pt (vlax-3d-point (getpoint "\nPick Insertion Point: ")))
 (setq vo (vlax-get-acad-object))
 (setq va (vla-get-activedocument vo))
 (setq vm (vla-get-modelspace va))
 (setq row (+ 1 (getreal "\How many stubs?")))
 (setq col  1)
 (setq dis (getdist "\What Is The First Stub Dimension? : "))
 (if (not (vl-string-search "" (setq strdis (rtos dis 4 4))))
     (setq strdis (strcat strdis "")))
 (setq tb (vla-addtable vm pt row col 1 1))
 (vla-put-titlesuppressed tb :vlax-false)
 (vla-put-headersuppressed tb :vlax-true)
 (vla-put-RegenerateTableSuppressed tb :vlax-true)
 (vla-put-vertcellmargin tb 0.1)
 (vla-put-horzcellmargin tb 0.25)
 (vla-setrowheight tb 0 0.3875)
 (vla-setcolumnwidth tb 0 2.2)
 
 (vla-settextstyle tb actitlerow "bold");title text style
 (vla-settextstyle tb acdatarow "Standard");data rows text style
 (vla-settextheight tb actitlerow 0.27);title text height = 0.27
 (vla-settextheight tb acdatarow 0.21);other cells text height = 0.21
 (vla-setalignment tb actitlerow acmiddlecenter);title alignment
 (vla-setalignment tb acdatarow acmiddlecenter);data cell alignment
 (vla-setformat tb acdatarow "arch");data cell format
 (vla-settext tb 0 0 "STUBS");title text
 
 (setq count 1)
 
 (while (< count row)
 (vla-setcelltextstyle tb count 0 "Standard")  
 (vla-setcelldatatype tb count 0 acdouble acunitdistance);optional  
 (vla-setrowheight tb count 0.3875)
 (if (=  count 1)
 (vla-settext tb count 0 strdis)    
 (vla-settext tb count 0 (strcat "= A2*" (itoa count))))
 (setq count (1+ count)))
 (vla-put-RegenerateTableSuppressed tb :vlax-false)
 
 (princ)
 );_ end
 

Link to comment
Share on other sites

This is what it has come up with, which actually i feel a little better because even thought it didnt work its something different to look at. I have'nt seen this error yet. ha but here it is.

 

Pick Insertion Point: How many stubs?14

What Is The First Stub Dimension? : 15.6295

; error: ActiveX Server returned the error: unknown name: ScaleFactor

Link to comment
Share on other sites

I suppose that just means its not one of the supported properties... (think thats right - wheres ASMI when you need him :P )

 

OK, I just tried performing this on an Insert:

 

(defun c:dump (/ ent obj)
 (while (setq ent (entsel "\nSelect entity to get object data: "))
   (print)
   (setq obj (vlax-ename->vla-object (car ent)))
   (vlax-dump-object obj t)
   (vlax-release-object obj)
   (princ "\n")
 )
 (princ)
)

 

And it listed these properties:

 

; IAcadBlockReference: AutoCAD Block Reference Interface
; Property values:
;   Application (RO) = #<VLA-OBJECT IAcadApplication 00b5e51c>
;   Document (RO) = #<VLA-OBJECT IAcadDocument 01f1b850>
;   Handle (RO) = "2DCC"
;   HasAttributes (RO) = 0
;   HasExtensionDictionary (RO) = 0
;   Hyperlinks (RO) = #<VLA-OBJECT IAcadHyperlinks 04aaca64>
;   InsertionPoint = (434.228 282.275 0.0)
;   Layer = "0"
;   Linetype = "BYLAYER"
;   LinetypeScale = 1.0
;   Lineweight = -1
;   Name = "TEST BLOCK"
;   Normal = (0.0 0.0 1.0)
;   ObjectID (RO) = 2130145312
;   ObjectName (RO) = "AcDbBlockReference"
;   OwnerID (RO) = 2130001088
;   PlotStyleName = "ByLayer"
;   Rotation = 0.0
;   TrueColor = #<VLA-OBJECT IAcadAcCmColor 04aac360>
;   Visible = -1
;   XScaleFactor = 1.0
;   YScaleFactor = 1.0
;   ZScaleFactor = 1.0
; Methods supported:
;   ArrayPolar (3)
;   ArrayRectangular (6)
;   Copy ()
;   Delete ()
;   Explode ()
;   GetAttributes ()
;   GetBoundingBox (2)
;   GetConstantAttributes ()
;   GetExtensionDictionary ()
;   GetXData (3)
;   Highlight (1)
;   IntersectWith (2)
;   Mirror (2)
;   Mirror3D (3)
;   Move (2)
;   Rotate (2)
;   Rotate3D (3)
;   ScaleEntity (2)
;   SetXData (2)
;   TransformBy (1)
;   Update ()

 

Which would lead me to think something like this:

 

(setq dimsc (getvar "dimscale"))
(vla-put-XScaleFactor tb dimsc)
(vla-put-YScaleFactor tb dimsc)
(vla-put-ZScaleFactor tb dimsc)

 

But I dunno :P

Link to comment
Share on other sites

Well i still didnt work it said error bad argument type vla-object nil so im not sure i guess im going to have to look at using more than 4 parenthesis which i try to avoid. its easier to think inside the box!

Link to comment
Share on other sites

I haven't actually looked at your posted LISP when supplying my advice - just using what little I know in the field of VL.

 

But now I do, I see that you use the command vla-addtable which doesn't seem to be recognised in my ACAD - how do you get this function to work?

Link to comment
Share on other sites

Are you trying to use it one the command line? i know that there are new commands in acad 2009 i know that the table is a vla object and pretty much all im doing is manipulating it. the vla-addtable just executes the insertion of the table.

Link to comment
Share on other sites

OK, that could be the issue - the commands were not recognised on my visual lisp editor - so I reckon they are new commands to '09.

 

But, if the "vla-addtable" executes a table insertion, then, (this may be a stupid question), wouldn't you set the variable "tb" to something along the lines of ("entlast"), then convert it to VLA-object or something. - although I am not sure what the return value is of the command vla-addtable. - It could be that the return is the VLA-object name.

 

Its worth a try anyway.

Link to comment
Share on other sites

well from what i did it actually returned vla-addtable so................

there has got to be some easy thing im missing. I should have stayed as a mechanic!

Link to comment
Share on other sites

Well from what i did it actually returned vla-addtable. There has got to be an easier way of doing this. I shouldve stayed being a mechanic!

Link to comment
Share on other sites

see thats the thing, it doesnt

all it shows is the vlax or vl functions but its not listed under the help file but if you google it you can find all kinds of stuff from autodesk.

Link to comment
Share on other sites

so by doing that it froze up my computer. but i just typed this in

 

Command: (vla-addtable 0 0)

; error: bad argument type: VLA-OBJECT 0

Link to comment
Share on other sites

Well, I mean to see the result of a valid use of vla-addtable.

 

The reason I bring this up is that you say that the error that occurs is:

 

vla-object nil - indicating to me that you haven't supplied the vla-put... with a valid object variable "tb".

 

I was suggesting you use something maybe of this format, without suppressing the last return, so that you could see what it was:

 

(defun C:ST2 (/ col count dis pt row strdis tb va vm vo)

 (setq pt (vlax-3d-point (getpoint "\nPick Insertion Point: ")))
 (setq vo (vlax-get-acad-object))
 (setq va (vla-get-activedocument vo))
 (setq vm (vla-get-modelspace va))
 (setq row (+ 1 (getreal "\How many stubs?")))
 (setq col 1)
 (setq dis (getdist "\What Is The First Stub Dimension? : "))
 (if (not (vl-string-search "" (setq strdis (rtos dis 4 4))))
   (setq strdis (strcat strdis ""))
 )
 (setq tb (vla-addtable vm pt row col 1 1))
)

 

But, as I say - I am new to VL, so I am just experimenting logically. :)

Link to comment
Share on other sites

Yes, I mean everything on the code works. The onlything that it lacks is, inserting into the right size so.. im still green around the gills too with this stuff

Link to comment
Share on other sites

here is the data

 

Command: dump

Select entity to get object data:

; IAcadTable2: IAcadTable2 Interface

; Property values:

; AllowManualHeights = 0

; AllowManualPositions = 0

; Application (RO) = #

; BreaksEnabled = 0

; BreakSpacing = 1.155

; Columns = 1

; ColumnWidth (RO) = ...Indexed contents not shown...

; Direction = (1.0 0.0 0.0)

; Document (RO) = #

; EnableBreak (RO) = ...Indexed contents not shown...

; FlowDirection = 0

; Handle (RO) = "B67"

; HasExtensionDictionary (RO) = 0

; HasSubSelection (RO) = 0

; HeaderSuppressed = -1

; Height = 7.28

; HorzCellMargin = 0.25

; Hyperlinks (RO) = #

; InsertionPoint = (-222.243 205.306 0.0)

; Layer = "Defpoints"

; Linetype = "ByLayer"

; LinetypeScale = 1.0

; Lineweight = -1

; Material = "ByLayer"

; MinimumTableHeight (RO) = 7.28

; MinimumTableWidth (RO) = 0.77

; ObjectID (RO) = 2129693944

; ObjectName (RO) = "AcDbTable"

; OwnerID (RO) = 2129665040

; PlotStyleName = "ByLayer"

; RegenerateTableSuppressed = 0

; RepeatBottomLabels = 0

; RepeatTopLabels = 0

; RowHeight (RO) = ...Indexed contents not shown...

; Rows = 15

; StyleName = "Standard"

; TableBreakFlowDirection = 1

; TableBreakHeight = 0.0

; TableStyleOverrides (RO) = (2 4 5 17 18 21 ... )

; TitleSuppressed = 0

; TrueColor = #

; VertCellMargin = 0.1

; Visible = -1

; Width = 2.2

; Methods supported:

; ArrayPolar (3)

; ArrayRectangular (6)

; ClearSubSelection ()

; ClearTableStyleOverrides (1)

; Copy ()

; CreateContent (3)

; Delete ()

; DeleteCellContent (2)

; DeleteColumns (2)

; DeleteContent (2)

; DeleteRows (2)

; EnableMergeAll (3)

; FormatValue (4)

; GenerateLayout ()

; GetAlignment (1)

; GetAttachmentPoint (2)

; GetAutoScale (2)

; GetAutoScale2 (3)

; GetBackgroundColor (1)

; GetBackgroundColorNone (1)

; GetBlockAttributeValue (3)

; GetBlockAttributeValue2 (4)

; GetBlockRotation (2)

; GetBlockScale (2)

; GetBlockTableRecordId (2)

; GetBlockTableRecordId2 (3)

; GetBoundingBox (2)

; GetBreakHeight (1)

; GetCellAlignment (2)

; GetCellBackgroundColor (2)

; GetCellBackgroundColorNone (2)

; GetCellContentColor (2)

; GetCellDataType (4)

; GetCellExtents (3)

; GetCellFormat (2)

; GetCellGridColor (3)

; GetCellGridLineWeight (3)

; GetCellGridVisibility (3)

; GetCellState (2)

; GetCellStyle (2)

; GetCellStyleOverrides (2)

; GetCellTextHeight (2)

; GetCellTextStyle (2)

; GetCellType (2)

; GetCellValue (2)

; GetColumnName (1)

; GetColumnWidth (1)

; GetContentColor (1)

; GetContentColor2 (3)

; GetContentLayout (2)

; GetContentType (2)

; GetCustomData (4)

; GetDataFormat (3)

; GetDataType (3)

; GetDataType2 (5)

; GetExtensionDictionary ()

; GetFieldId (2)

; GetFieldId2 (3)

; GetFormat (1)

; GetFormula (3)

; GetGridColor (2)

; GetGridColor2 (3)

; GetGridDoubleLineSpacing (3)

; GetGridLineStyle (3)

; GetGridLinetype (3)

; GetGridLineWeight (2)

; GetGridLineWeight2 (3)

; GetGridVisibility (2)

; GetGridVisibility2 (3)

; GetHasFormula (3)

; GetMargin (3)

; GetMinimumColumnWidth (1)

; GetMinimumRowHeight (1)

; GetOverride (3)

; GetRotation (3)

; GetRowHeight (1)

; GetRowType (1)

; GetScale (3)

; GetSubSelection (4)

; GetText (2)

; GetTextHeight (1)

; GetTextHeight2 (3)

; GetTextRotation (2)

; GetTextString (3)

; GetTextStyle (1)

; GetTextStyle2 (3)

; GetValue (3)

; GetXData (3)

; Highlight (1)

; HitTest (4)

; InsertColumns (3)

; InsertColumnsAndInherit (3)

; InsertRows (3)

; InsertRowsAndInherit (3)

; IntersectWith (2)

; IsContentEditable (2)

; IsEmpty (2)

; IsFormatEditable (2)

; IsMergeAllEnabled (2)

; IsMergedCell (6)

; MergeCells (4)

; Mirror (2)

; Mirror3D (3)

; Move (2)

; MoveContent (4)

; RecomputeTableBlock (1)

; RemoveAllOverrides (2)

; ReselectSubRegion ()

; ResetCellValue (2)

; Rotate (2)

; Rotate3D (3)

; ScaleEntity (2)

; Select (8)

; SelectSubRegion (10)

; SetAlignment (2)

; SetAutoScale (3)

; SetAutoScale2 (4)

; SetBackgroundColor (2)

; SetBackgroundColorNone (2)

; SetBlockAttributeValue (4)

; SetBlockAttributeValue2 (5)

; SetBlockRotation (3)

; SetBlockScale (3)

; SetBlockTableRecordId (4)

; SetBlockTableRecordId2 (5)

; SetBreakHeight (2)

; SetCellAlignment (3)

; SetCellBackgroundColor (3)

; SetCellBackgroundColorNone (3)

; SetCellContentColor (3)

; SetCellDataType (4)

; SetCellFormat (3)

; SetCellGridColor (4)

; SetCellGridLineWeight (4)

; SetCellGridVisibility (4)

; SetCellState (3)

; SetCellStyle (3)

; SetCellTextHeight (3)

; SetCellTextStyle (3)

; SetCellType (3)

; SetCellValue (3)

; SetCellValueFromText (4)

; SetColumnName (2)

; SetColumnWidth (2)

; SetContentColor (2)

; SetContentColor2 (4)

; SetContentLayout (3)

; SetCustomData (4)

; SetDataFormat (4)

; SetDataType (3)

; SetDataType2 (5)

; SetFieldId (3)

; SetFieldId2 (5)

; SetFormat (2)

; SetFormula (4)

; SetGridColor (3)

; SetGridColor2 (4)

; SetGridDoubleLineSpacing (4)

; SetGridLineStyle (4)

; SetGridLinetype (4)

; SetGridLineWeight (3)

; SetGridLineWeight2 (4)

; SetGridVisibility (3)

; SetGridVisibility2 (4)

; SetMargin (4)

; SetOverride (4)

; SetRotation (4)

; SetRowHeight (2)

; SetScale (4)

; SetSubSelection (4)

; SetText (3)

; SetTextHeight (2)

; SetTextHeight2 (4)

; SetTextRotation (3)

; SetTextString (4)

; SetTextStyle (2)

; SetTextStyle2 (4)

; SetToolTip (3)

; SetValue (4)

; SetValueFromText (5)

; SetXData (2)

; TransformBy (1)

; UnmergeCells (4)

; Update ()

 

Select entity to get object data:

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...